Compare commits

...

114 Commits

Author SHA1 Message Date
Giteabot
726d6a5077 Add CHANGELOG for 1.19.0 (#23583) (#23586)
Backport #23583 by @delvh

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-20 16:34:28 +08:00
yp05327
b33cae7a3a Fix backport #23336 (#23584) 2023-03-20 15:37:20 +08:00
wxiaoguang
854fcb1434 Fix dropdown icon misalignment when using fomantic icon (#23558) (#23577)
Backport #23558

There are still many dropdowns using fomantic icon. For example: new
issue with issue template.

Avoid polluting the fomantic styles.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-20 10:44:15 +08:00
Giteabot
4730ed18f1 Add .patch to attachment.ALLOWED_TYPES (#23580) (#23582)
Backport #23580 by @silverwind

Updated this default to GitHub's latest, adding the `.patch` file
extension to allowed types.

Co-authored-by: silverwind <me@silverwind.io>
2023-03-19 16:48:44 -04:00
Giteabot
937996c74c Match api migration behavior to web behavior (#23552) (#23573)
Backport #23552 by @atomaka

When attempting to migrate a repository via the API endpoint comments
are always included. This can create a problem if your source repository
has issues or pull requests but you do not want to import them into
Gitea that displays as something like:

> Error 500: We were unable to perform the request due to server-side
problems. 'comment references non existent IssueIndex 4

There are only two ways to resolve this:
1. Migrate using the web interface
2. Migrate using the API including at issues or pull requests.

This PR matches the behavior of the API migration router to the web
migration router.

Co-authored-by: Andrew Tomaka <atomaka@atomaka.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-19 15:30:02 +08:00
Giteabot
3f253b3f5a Fix some broken css (#23560) (#23567)
Backport #23560 by @wxiaoguang

1. The "close" inside "modal" are likely broken for long time
    * There is no var called `--body-color`
    * There is no `fullscreen modal`
* The `.ui.modal > .close.inside` doesn't seem to match most icons. It
only matches a few like "fork-repo-modal" or "adopt repo". Other places
are just buggy code copied again and again.
2. Convert the legacy `&:hover` LESS syntax to CSS syntax

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
2023-03-18 21:37:16 -04:00
Giteabot
f5a98b0f5b Fix sticky header in diff view (#23554) (#23568)
Backport #23554 by @silverwind

Ressurection of #23549.

Fix regression
https://github.com/go-gitea/gitea/pull/23513#issuecomment-1474356817
from #23271.
The previous sticky CSS did assume the content is always 2 rows, but
since that PR, it's single-row above 993px width.
Adjust the sticky offset to match and add a small tweak that hides
content behind the `border-radius`.

Single row:
<img width="1264" alt="Screenshot 2023-03-17 at 21 33 05"
src="https://user-images.githubusercontent.com/115237/226034050-a04b131d-fd3f-45c0-bc72-413738a59825.png">

Double row:
<img width="1243" alt="Screenshot 2023-03-17 at 21 32 53"
src="https://user-images.githubusercontent.com/115237/226034163-2f1c6aa9-fc72-432f-bc46-9a7119da8677.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-19 01:29:16 +01:00
Giteabot
1a97a84023 Fix JS error on compare page (#23551) (#23566)
Backport #23551 by @silverwind

Fix regression from https://github.com/go-gitea/gitea/pull/23271. This
code apparently runs on the compare page where there is no review button
so check for existance of both button and content.

<img width="1226" alt="Screenshot 2023-03-17 at 21 42 47"
src="https://user-images.githubusercontent.com/115237/226040001-ec097edd-d926-4c80-9962-526f9b7eff19.png">

Fixes #23562

Co-authored-by: silverwind <me@silverwind.io>
2023-03-18 16:48:13 -05:00
wxiaoguang
420d015b76 Fix aria.js bugs: incorrect role element problem, mobile focus problem, tippy problem (#23450) (#23486)
Before: the `aria.js` is still buggy in some cases.

After: tested with AppleVoice, Android TalkBack (I tested it with 1.19
again)

* Fix incorrect dropdown init code
* Fix incorrect role element (the menu role should be on the `$menu`
element, but not on the `$focusable`)
* Fix the focus-show-click-hide problem on mobile. Now the language menu
works as expected
* Fix incorrect dropdown template function setting
* Clarify the logic in aria.js
* Fix incorrect tippy `setProps` after `destroy`
* Improve comments
* Implement the layout proposed by #19861
2023-03-18 17:14:19 +01:00
Giteabot
22911a1ece Imrove scroll behavior to hash issuecomment(scroll position, auto expand if file is folded, and on refreshing) (#23513) (#23540)
Backport #23513 by @HesterG

Close #23466
Right now on pull request "files Changed" tab, if a file is viewed, when
the comments' links are visited, the comment will not be shown as the
file is folded after viewed. This PR is to improve the behavior, to make
the comment seen even the related file is folded, like on github.

And right now scroll position will be remembered and hence it won’t
scroll to hashed comment after refreshing, this PR also adjust the
scroll position remembering behavior: When there is hash comment in url,
do not remember the scroll position.

Before:


https://user-images.githubusercontent.com/17645053/225512079-6cf79581-9346-44cf-95d6-06919642e6a8.mov


After:


https://user-images.githubusercontent.com/17645053/225523753-3f6728f2-977b-4ed0-a65c-63dcef2ace80.mov


Update - long comment's behavior after using `scrollTop ` (Comment div
scroll to the position which is 30px below the diff header, or 30px
below top on conversation tab):


https://user-images.githubusercontent.com/17645053/225614460-0602c1a6-229c-41f4-84d2-334e78251486.mov

Co-authored-by: Hester Gong <hestergong@gmail.com>
2023-03-17 22:59:18 -04:00
Giteabot
4b763d8d37 Fix diff detail buttons wrapping, use tippy for review box (#23271) (#23546)
Backport #23271 by @silverwind

Fix visual regression introduced by
https://github.com/go-gitea/gitea/pull/22986.

Before:
<img width="1277" alt="image"
src="https://user-images.githubusercontent.com/115237/222792814-d70c2173-0c7c-4db2-8839-95be63cdc8ee.png">
<img width="649" alt="image"
src="https://user-images.githubusercontent.com/115237/222792989-9b1f5e12-becd-40cc-b02c-e9f59a8e72a4.png">

After: 
<img width="1274" alt="image"
src="https://user-images.githubusercontent.com/115237/222792769-e7a9702f-4b6a-46c4-9385-da103ed4dff0.png">
<img width="565" alt="image"
src="https://user-images.githubusercontent.com/115237/222793084-6de6482b-11dc-4d38-b514-15884d20e140.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-17 14:52:04 -04:00
wxiaoguang
1254fc668a Fix review comment context menu clipped bug (#23523) (#23543)
Backport #23523, Close #23517

There is no "dropdown menu" for image/csv view, so we could only add the
"overflow-x: scroll" to the image/csv view.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-17 14:00:17 -04:00
wxiaoguang
09824025f7 Refactor merge/update git command calls (#23366) (#23544)
Backport #23366

* Remove unnecessary ToTrustedCmdArgs calls
* The `signArg` couldn't be empty, it's either `-S{keyID}` or
`--no-gpg-sign`.
2023-03-17 12:16:22 -04:00
Giteabot
bd1a915bdb Use octicon-verified for gpg signatures (#23529) (#23536)
Backport #23529 by @silverwind

Before:
<img width="292" alt="Screenshot 2023-03-16 at 23 40 47"
src="https://user-images.githubusercontent.com/115237/225768871-43e11ced-e340-4c88-b756-25f9f7076fd2.png">
<img width="288" alt="Screenshot 2023-03-16 at 23 51 05"
src="https://user-images.githubusercontent.com/115237/225770071-b51f3ed6-ef14-421b-a5bc-6a26e808d404.png">


After:
<img width="291" alt="Screenshot 2023-03-16 at 23 40 37"
src="https://user-images.githubusercontent.com/115237/225768864-ea4956c7-8c57-4148-9d89-c818991a7538.png">
<img width="281" alt="image"
src="https://user-images.githubusercontent.com/115237/225769978-0b9c6c52-9a13-4c23-b13e-8a8a692abf43.png">

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-17 11:39:31 -04:00
Giteabot
cab7044772 Increase horizontal page padding (#23507) (#23537)
Backport #23507 by @silverwind

Add a bit more empty space on left and right side of page content for a
more pleasant viewing experience. Also tweaked the mobile navbar to
match.

Before:
<img width="1276" alt="Screenshot 2023-03-16 at 00 58 23"
src="https://user-images.githubusercontent.com/115237/225473942-f544106f-1b61-456a-99fb-3ba136cabc8d.png">

After:
<img width="1270" alt="Screenshot 2023-03-16 at 00 58 37"
src="https://user-images.githubusercontent.com/115237/225473959-8b555359-a08d-48e1-9476-2710aabb1166.png">

Mobile Navbar:
<img width="673" alt="Screenshot 2023-03-16 at 01 05 12"
src="https://user-images.githubusercontent.com/115237/225473966-adccef2b-4d34-44ed-8c75-d4ca46d96cf3.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-17 21:01:47 +08:00
Giteabot
68c9f1abd8 Use <nav> instead of <div> in the global navbar (#23125) (#23533)
Backport #23125 by @delvh

Furthermore improved/deleted some comments in the template.
The appearance did not change.

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-17 01:28:17 -04:00
Zettat123
301de3ab6b Handle missing README in create repos API (#23387) (#23510)
Backport #23387 
Close #22934

In `/user/repos` API (and other APIs related to creating repos), user
can specify a readme template for auto init. At present, if the
specified template does not exist, a `500` will be returned . This PR
improved the logic and will return a `400` instead of `500`.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-16 21:04:52 -04:00
silverwind
8f8bd3c0cb Replace Less with CSS (#23508)
Backport https://github.com/go-gitea/gitea/pull/23481,
https://github.com/go-gitea/gitea/pull/23504 and
https://github.com/go-gitea/gitea/pull/23520 to 1.19, just so we have an
easier time with future backports.

Seems to work on a basic level. There was a merge conflict in
`RepoActionView.vue`, otherwise it merged cleanly.

---------

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-03-16 21:04:39 -04:00
Giteabot
23a6fa9421 Make time tooltips interactive (#23526) (#23527)
Backport #23526 by @silverwind

Fixes https://codeberg.org/forgejo/forgejo/issues/511

<img width="379" alt="Screenshot 2023-03-16 at 20 23 10"
src="https://user-images.githubusercontent.com/115237/225731294-4c6e4f44-bdcc-4c8c-86e2-49f7c03b377d.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-16 16:23:11 -05:00
Jason Song
b7c2f48ebf Update act (#23512) (#23518)
Backport #23512.

Update replace:
```diff
- replace github.com/nektos/act => gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744
+ replace github.com/nektos/act => gitea.com/gitea/act v0.243.1
```

Update require:
```diff
-	github.com/nektos/act v0.0.0
+	github.com/nektos/act v0.2.43
```

Actually, `v0.2.43` doesn't work, it will be replaced by `gitea/act`, so
it's OK to put any version here. But `gitea/act` is based on
`nektos/act`, so keeping the right upstream version will make security
dependabot help.

BTW, the [security
report](https://github.com/go-gitea/gitea/security/dependabot/20) is
false positive, we don't use the artifact server in act, see #22738.
2023-03-16 09:33:11 -05:00
Giteabot
70e31b4aa0 Update path to docs theme file (#23502) (#23505)
Backport #23502 by @techknowlogick

The branch name for the theme was updated to main

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-15 16:04:27 -05:00
Giteabot
d73846f0b4 Disable sending email after push a commit to a closed PR (#23462) (#23492)
Backport #23462 by @sillyguodong

Close #23440
Cause by #23189
In #23189, we should insert a comment record into db when pushing a
commit to the PR, even if the PR is closed.
But should skip sending any notification in this case.

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-03-15 11:20:51 +01:00
Giteabot
527bbf67e8 Fix 'View File' button in code search (#23478) (#23483)
Backport #23478 by @silverwind

- Right-align 'View File' button
- Add 'role' attribute to button link

Before:
<img width="1148" alt="Screenshot 2023-03-14 at 22 02 16"
src="https://user-images.githubusercontent.com/115237/225135954-f06153ec-c222-441e-98ba-0177afff3a7a.png">

After:
<img width="1150" alt="Screenshot 2023-03-14 at 22 02 33"
src="https://user-images.githubusercontent.com/115237/225135966-323cb695-05ef-4b83-a8ef-05f2b1887090.png">

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-03-15 10:34:05 +01:00
Giteabot
5feb31f219 Bump webpack from 5.75.0 to 5.76.0 (#23484) (#23487)
Backport #23484 by @dependabot[bot]

Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to
5.76.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/webpack/webpack/releases">webpack's
releases</a>.</em></p>
<blockquote>
<h2>v5.76.0</h2>
<h2>Bugfixes</h2>
<ul>
<li>Avoid cross-realm object access by <a
href="https://github.com/Jack-Works"><code>@​Jack-Works</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16500">webpack/webpack#16500</a></li>
<li>Improve hash performance via conditional initialization by <a
href="https://github.com/lvivski"><code>@​lvivski</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16491">webpack/webpack#16491</a></li>
<li>Serialize <code>generatedCode</code> info to fix bug in asset module
cache restoration by <a
href="https://github.com/ryanwilsonperkin"><code>@​ryanwilsonperkin</code></a>
in <a
href="https://redirect.github.com/webpack/webpack/pull/16703">webpack/webpack#16703</a></li>
<li>Improve performance of <code>hashRegExp</code> lookup by <a
href="https://github.com/ryanwilsonperkin"><code>@​ryanwilsonperkin</code></a>
in <a
href="https://redirect.github.com/webpack/webpack/pull/16759">webpack/webpack#16759</a></li>
</ul>
<h2>Features</h2>
<ul>
<li>add <code>target</code> to <code>LoaderContext</code> type by <a
href="https://github.com/askoufis"><code>@​askoufis</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16781">webpack/webpack#16781</a></li>
</ul>
<h2>Security</h2>
<ul>
<li><a
href="https://github.com/advisories/GHSA-3rfm-jhwj-7488">CVE-2022-37603</a>
fixed by <a
href="https://github.com/akhilgkrishnan"><code>@​akhilgkrishnan</code></a>
in <a
href="https://redirect.github.com/webpack/webpack/pull/16446">webpack/webpack#16446</a></li>
</ul>
<h2>Repo Changes</h2>
<ul>
<li>Fix HTML5 logo in README by <a
href="https://github.com/jakebailey"><code>@​jakebailey</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16614">webpack/webpack#16614</a></li>
<li>Replace TypeScript logo in README by <a
href="https://github.com/jakebailey"><code>@​jakebailey</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16613">webpack/webpack#16613</a></li>
<li>Update actions/cache dependencies by <a
href="https://github.com/piwysocki"><code>@​piwysocki</code></a> in <a
href="https://redirect.github.com/webpack/webpack/pull/16493">webpack/webpack#16493</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/Jack-Works"><code>@​Jack-Works</code></a> made
their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16500">webpack/webpack#16500</a></li>
<li><a href="https://github.com/lvivski"><code>@​lvivski</code></a> made
their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16491">webpack/webpack#16491</a></li>
<li><a
href="https://github.com/jakebailey"><code>@​jakebailey</code></a> made
their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16614">webpack/webpack#16614</a></li>
<li><a
href="https://github.com/akhilgkrishnan"><code>@​akhilgkrishnan</code></a>
made their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16446">webpack/webpack#16446</a></li>
<li><a
href="https://github.com/ryanwilsonperkin"><code>@​ryanwilsonperkin</code></a>
made their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16703">webpack/webpack#16703</a></li>
<li><a href="https://github.com/piwysocki"><code>@​piwysocki</code></a>
made their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16493">webpack/webpack#16493</a></li>
<li><a href="https://github.com/askoufis"><code>@​askoufis</code></a>
made their first contribution in <a
href="https://redirect.github.com/webpack/webpack/pull/16781">webpack/webpack#16781</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/webpack/webpack/compare/v5.75.0...v5.76.0">https://github.com/webpack/webpack/compare/v5.75.0...v5.76.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="97b1718720"><code>97b1718</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16781">#16781</a>
from askoufis/loader-context-target-type</li>
<li><a
href="b84efe6224"><code>b84efe6</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16759">#16759</a>
from ryanwilsonperkin/real-content-hash-regex-perf</li>
<li><a
href="c98e9e0014"><code>c98e9e0</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16493">#16493</a>
from piwysocki/patch-1</li>
<li><a
href="5f34acfbc0"><code>5f34acf</code></a>
feat: Add <code>target</code> to <code>LoaderContext</code> type</li>
<li><a
href="b7fc4d876d"><code>b7fc4d8</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16703">#16703</a>
from ryanwilsonperkin/ryanwilsonperkin/fix-16160</li>
<li><a
href="63ea82da4d"><code>63ea82d</code></a>
Merge branch 'webpack:main' into patch-1</li>
<li><a
href="4ba225225b"><code>4ba2252</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16446">#16446</a>
from akhilgkrishnan/patch-1</li>
<li><a
href="1acd6350be"><code>1acd635</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16613">#16613</a>
from jakebailey/ts-logo</li>
<li><a
href="302eb37fe1"><code>302eb37</code></a>
Merge pull request <a
href="https://redirect.github.com/webpack/webpack/issues/16614">#16614</a>
from jakebailey/html5-logo</li>
<li><a
href="cfdb1dfe59"><code>cfdb1df</code></a>
Improve performance of hashRegExp lookup</li>
<li>Additional commits viewable in <a
href="https://github.com/webpack/webpack/compare/v5.75.0...v5.76.0">compare
view</a></li>
</ul>
</details>
<details>
<summary>Maintainer changes</summary>
<p>This version was pushed to npm by <a
href="https://www.npmjs.com/~evilebottnawi">evilebottnawi</a>, a new
releaser for webpack since your current version.</p>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=webpack&package-manager=npm_and_yarn&previous-version=5.75.0&new-version=5.76.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the
default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as
the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as
the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the
default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/go-gitea/gitea/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-15 14:21:59 +08:00
Giteabot
31efbafbe3 Convert GitHub event on actions and fix some pull_request events. (#23037) (#23471)
Backport #23037 by @lunny

Follow #22680

Partially Fix #22958, on pull_request, `opened`, `reopened`,
`synchronize` supported, `edited` hasn't been supported yet because
Gitea doesn't trigger that events.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: yp05327 <576951401@qq.com>
2023-03-15 10:43:10 +08:00
Giteabot
28af02eea0 Fix due date being wrong on issue list (#23475) (#23477)
Backport #23475 by @yardenshoham

Exactly like #22302 but in the issue list page

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-15 09:40:43 +08:00
Giteabot
c698a6fc5d Scoped label display and documentation tweaks (#23430) (#23433)
Backport #23430 by @brechtvl

* Fix scoped label left and right part breaking across lines.
* Remove slanted divider in scoped label display, make it straight.
After using this for a while, this feels more visually noisy than
helpful.
* Reduce contrast between scope and item to reduce probability of
unreadable text on background.
* Change documentation to remove mention of non-exclusive scoped labels.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-03-15 07:58:38 +08:00
Giteabot
e5a51eca45 Remove wrongly added column on migration test fixtures (#23456) (#23470)
Backport #23456 by @lunny

Fix https://drone.gitea.io/go-gitea/gitea/69418/3/8
Migration fixtures are in `models/migrations/fixtures`, every folder
will be used only by the test with the same name.
For `Test_DeleteOrphanedIssueLabels`, the fixture should keep consistent
as the database structure at that time. So the newly added `exclusive`
is not right. Just revert the change in
https://github.com/go-gitea/gitea/pull/22585/files#diff-f8db9cbbaa10bf7b27eb726884454db821a4b4f8cb9a0d50435555908761bbcb

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-14 16:09:52 -04:00
Giteabot
8536dc4b73 Make branches list page operations remember current page (#23420) (#23460)
Backport #23420 by @wxiaoguang

Close #23411

Always pass "page" query parameter to backend, and make backend respect
it.

The `ctx.FormInt("limit")` is never used, so removed.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-14 20:51:14 +08:00
techknowlogick
0a0f46f299 test_env: hardcode major go version in use (#23464) 2023-03-14 04:12:14 -04:00
Giteabot
1543ac9c8d Fix missing commit status in PR which from forked repo (#23351) (#23453)
Backport #23351 by @sillyguodong

close: #23347

### Reference and Inference
According to Github REST API
[doc](https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#list-commit-statuses-for-a-reference):
1. The `Drone CI` that can create some commit status by
[API](https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status)
is enabled in `go-gitea/gitea`. So I tried to call the API to get a
commit status list of a PR which is commited to upstream
repo(`go-gitea/gitea`). As a result, the API returned a array of commit
status.

![image](https://user-images.githubusercontent.com/33891828/223913371-313d047a-5e2e-484c-b13e-dcd38748703e.png)
2. Then I tried to call the API to get commit status list of the
reference which of the `SHA` is the same as step 1 in the repo which is
forked from `go-gitea/gitea`. But I got a empty array.

![image](https://user-images.githubusercontent.com/33891828/223930827-17a64d3c-f466-4980-897c-77fe386c4d3b.png)

So, I believe it that:
1. The commit status is not shared between upstream repo and forked
repo.
2. The coomit status is bound to a repo that performs actions. (Gitea's
logic is the same)

### Cause
During debugging, I found it that commit status are not stored in the DB
as expected.
So, I located the following code:

8cadd51bf2/services/actions/commit_status.go (L18-L26)
When I create a PR, the type of `event` is `pull request`, not `push`.
So the code return function directly.

### Screenshot

![image](https://user-images.githubusercontent.com/33891828/223939339-dadf539c-1fdd-40c4-96e9-2e4fa733f531.png)

![image](https://user-images.githubusercontent.com/33891828/223939519-edb02bf0-2478-4ea5-9366-be85468f02db.png)

![image](https://user-images.githubusercontent.com/33891828/223939557-ec6f1375-5536-400e-8987-fb7d2fd452fa.png)

### Other 
In this PR, I also fix the problem of missing icon which represents
running in PRs list.

![image](https://user-images.githubusercontent.com/33891828/223939898-2a0339e4-713f-4c7b-9d99-2250a43f3457.png)

![image](https://user-images.githubusercontent.com/33891828/223939979-037a975f-5ced-480c-bac7-0ee00ebfff4b.png)

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
2023-03-14 08:11:31 +08:00
Giteabot
c3c0710412 Purge API comment (#23451) (#23452)
Backport #23451 by @jolheiser

This PR just adds the `purge` query parameter to the swagger docs for
admin user delete.

I considered using the same verbiage we have in the UI, but that seemed
more verbose than descriptions we use elsewhere in swagger. I'm fine if
that's preferred, though, just let me know. 🙂

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-03-13 15:46:18 -05:00
Giteabot
fa33919e24 Support reflogs (#22451) (#23438)
Backport #22451 by @philip-peterson

This PR adds support for reflogs on all repositories. It does this by
adding a global configuration entry.

Implements #14865

Signed-off-by: Philip Peterson <philip.c.peterson@gmail.com>
Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
2023-03-13 12:20:10 +00:00
Giteabot
b1162495af Fix actions frontend bugs (pagination, long name alignment) and small simplify (#23370) (#23436)
Backport #23370 by @HesterG

1 Right now on actions page, the action list will not be aligned if
commit message is long. In this PR, the changes are:
- The branch tag is moved to bottom row
- Width percentage is given to make them aligned
- Show "..." if commit is longer than two lines.
- Align the status icon with the commit message with baseline

 Before:
<img width="1068" alt="截屏2023-03-08 12 23 22"
src="https://user-images.githubusercontent.com/17645053/223628534-6b9472cb-29f5-40a3-9714-c5152553049e.png">
  
 After:
<img width="756" alt="截屏2023-03-08 13 34 28"
src="https://user-images.githubusercontent.com/17645053/223628571-da94698b-0e0a-43e3-ae82-34d8c780e5ba.png">


2 Right now the actions list's pagination is not working properly
because Param is not passed to pagination template, in this PR Param
Strings are passed to the pager

Before:
<img width="1176" alt="截屏2023-03-08 12 23 50"
src="https://user-images.githubusercontent.com/17645053/223629207-8b67ce74-2342-4259-bc81-036e37752716.png">

After:
<img width="1343" alt="截屏2023-03-08 13 11 54"
src="https://user-images.githubusercontent.com/17645053/223629321-4f538f8a-45dc-4d6f-ae60-2c82680ae3e7.png">

3 A small simplify in `RepoActionView.vue` .

Co-authored-by: Hester Gong <hestergong@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-13 09:09:00 +02:00
Giteabot
41655ee878 Show edit/close/delete button on organization wide repositories (#23388) (#23429)
Backport #23388 by @yp05327

A part of https://github.com/go-gitea/gitea/pull/22865

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-12 15:17:25 +01:00
Giteabot
0d9b44c0e3 Preserve file size when creating attachments (#23406) (#23426)
Backport #23406 by @baez90

When creating attachments (issue, release, repo) the file size (being
part of the multipart file header) is passed through the chain of
creating an attachment to ensure the MinIO client can stream the file
directly instead of having to read it to memory completely at first.

Fixes #23393

Co-authored-by: Peter <peter.kurfer@googlemail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-12 12:45:39 +01:00
Giteabot
e87f36e885 Use buildkit for docker builds (#23415) (#23424) 2023-03-11 17:11:23 -05:00
Giteabot
b301cb17a3 Fix and move "Use this template" button (#23398) (#23408)
Backport #23398

Before:
<img width="1157" alt="Screenshot 2023-03-09 at 23 21 25"
src="https://user-images.githubusercontent.com/115237/224174168-869966cc-fa59-4231-b449-23bd9db12862.png">

After:
<img width="1145" alt="Screenshot 2023-03-09 at 23 24 34"
src="https://user-images.githubusercontent.com/115237/224174173-7f5b9c22-44c4-4eed-990c-da49d749eb0e.png">

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-11 01:41:04 +08:00
Giteabot
e259daeff8 Add missing tabs to org projects page (#22705) (#23412)
Backport #22705 by @yp05327

Fixes https://github.com/go-gitea/gitea/issues/22676

Context Data `IsOrganizationMember` and `IsOrganizationOwner` is used to
control the visibility of `people` and `team` tab.

2871ea0809/templates/org/menu.tmpl (L19-L40)

And because of the reuse of user projects page, User Context is changed
to Organization Context. But the value of `IsOrganizationMember` and
`IsOrganizationOwner` are not being given.

I reused func `HandleOrgAssignment` to add them to the ctx, but may have
some unnecessary variables, idk whether it is ok.

I found there is a missing `PageIsViewProjects` at create project page.

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-10 10:08:28 -06:00
Giteabot
edb618c136 Handle OpenID discovery URL errors a little nicer when creating/editing sources (#23397) (#23403)
Backport #23397

When there is an error creating a new openIDConnect authentication
source try to handle the error a little better.

Close #23283

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2023-03-10 08:29:28 -06:00
Giteabot
43cf04c031 Fix broken Chroma CSS styles (#23174) (#23402)
Backport #23174

The CSS styles in Gitea themes are out-of-sync of Chroma's styles.

This PR introduces a `chroma-style-diff.go` tool to compare the diff.
The missing CSS styles have been added manually. They are left as empty
to reduce arguments because there was no color for them before.

And this PR fixes #22348, with just 2 lines changed: `.chroma .kt & .n`,
these colors are taken from GitHub.

It's good enough for #22348


![image](https://user-images.githubusercontent.com/2114189/221551941-0d27d11d-e71e-498f-8e88-92b558fe4a18.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-03-10 19:45:07 +08:00
Giteabot
e9991b1f06 Refactor and tidy-up the merge/update branch code (#22568) (#23365)
Backport #22568

The merge and update branch code was previously a little tangled and had
some very long functions. The functions were not very clear in their
reasoning and there were deficiencies in their logging and at least one
bug in the handling of LFS for update by rebase.

This PR substantially refactors this code and splits things out to into
separate functions. It also attempts to tidy up the calls by wrapping
things in "context"s. There are also attempts to improve logging when
there are errors.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <dev.lh@web.de>
2023-03-09 22:15:39 -05:00
Giteabot
975785dd42 Rename canWriteUnit to canWriteProjects (#23386) (#23399)
Backport #23386

A part of https://github.com/go-gitea/gitea/pull/22865

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-09 21:21:12 -05:00
Giteabot
e269e8901f Fix incorrect NotFound conditions in org/projects.go (#23384) (#23395)
Backport #23384

A part of https://github.com/go-gitea/gitea/pull/22865

user/org project's `RepoID` is always 0, we need to check `OwnerID`

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-09 13:56:31 -06:00
Giteabot
87c31c2ffe Set X-Gitea-Debug header once (#23361) (#23381) 2023-03-09 06:33:05 +08:00
Giteabot
54c674c936 Fix panic when getting notes by ref (#23372) (#23377)
Backport #23372

Fix #23357 .

Now the `/repos/{owner}/{repo}/git/notes/{sha}` API supports getting
notes by a ref or sha
(https://try.gitea.io/api/swagger#/repository/repoGetNote). But the
`GetNote` func can only accept commit ID.

a12f575737/modules/git/notes_nogogit.go (L18)

So we need to convert the query parameter to commit ID before calling
`GetNote`.

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-08 15:17:31 -05:00
delvh
2ba58fab22 Pass context to avatar for projects view (#23359) (#23378)
Backport of #23359.

Previously, a 500 response was returned when

- an issue had assignees
- the issue was assigned to a project
- you tried to view this project
2023-03-08 11:57:09 -06:00
wxiaoguang
cd7bd8568c Fix incorrect display for comment context menu (#23343) (#23344)
Backport #23343

Fix a regression of #23014: the `a` couldn't be used here because
Fomantic UI has style conflicts: `.ui.comments .comment .actions a {
display: inline-block; }`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-08 23:18:53 +08:00
Giteabot
cf80f829b4 Do not recognize text files as audio (#23355) (#23368)
Backport #23355

Close #17108

This PR uses a trick (removing the ID3 tag) to detect the content again
to to see whether the content is text type.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-08 16:03:05 +08:00
Giteabot
ed25e094ab Fix adding of empty class name (#23352) (#23360)
Backport #23352

This PR is to fix the error shown below. The reason is because
[`class-name`
prop](https://github.com/go-gitea/gitea/blob/main/web_src/js/components/ActionRunStatus.vue#L6)
given to `svg` component has a space, and classList cannot add empty
string.



https://user-images.githubusercontent.com/17645053/223346720-c7f9de43-5e69-4ecf-93c0-90bf04090693.mov

Co-authored-by: Hester Gong <hestergong@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-07 17:15:19 -05:00
Giteabot
10df304b2f Fix various ImageDiff/SVG bugs (#23312) (#23358)
Backport #23312

Replace #23310, Close #19733

And fix various UI problems, including regressions from #22959 #22950
and more.


## SVG Detection

The old regexp may mismatch non-SVG files. This PR adds new tests for
those cases.

## UI Changes

### Before


![image](https://user-images.githubusercontent.com/2114189/222967716-f6ad8721-f46a-4a3f-9eb0-a89e488d3436.png)


![image](https://user-images.githubusercontent.com/2114189/222967780-8af8981a-e69d-4304-9dc4-0235582fa4f4.png)


### After


![image](https://user-images.githubusercontent.com/2114189/222967575-c21c23d4-0200-4e09-aac3-57895e853000.png)


![image](https://user-images.githubusercontent.com/2114189/222967585-8b8da262-bc96-441a-9851-8d3845f2659d.png)


![image](https://user-images.githubusercontent.com/2114189/222967595-58d9bea5-6df4-41fa-bf8a-86704117959d.png)


![image](https://user-images.githubusercontent.com/2114189/222967608-38757c1a-b8bd-4ebf-b7a8-3b30edb7f303.png)


![image](https://user-images.githubusercontent.com/2114189/222967623-9849a339-6fae-4484-8fa5-939e2fdacbf5.png)


![image](https://user-images.githubusercontent.com/2114189/222967633-4383d7dd-62ba-47a3-8c10-86f7ca7757ae.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-07 15:38:13 +02:00
Giteabot
ecae62837c Refactor setting.Database.UseXXX to methods (#23354) (#23356)
Backport #23354

Replace #23350.

Refactor `setting.Database.UseMySQL` to
`setting.Database.Type.IsMySQL()`.

To avoid mismatching between `Type` and `UseXXX`.

This refactor can fix the bug mentioned in #23350, so it should be
backported.

Co-authored-by: Jason Song <i@wolfogre.com>
2023-03-07 20:11:44 +08:00
sillyguodong
e8e871b44e Fix cannot reopen after pushing commits to a closed PR (#23189) (#23324)
Backport: #23189 
Close: #22784

1. On GH, we can reopen a PR which was closed before after pushing
commits. After reopening PR, we can see the commits that were pushed
after closing PR in the time line. So the case of
[issue](https://github.com/go-gitea/gitea/issues/22784) is a bug which
needs to be fixed.

2. After closing a PR and pushing commits, `headBranchSha` is not equal
to `sha`(which is the last commit ID string of reference). If the
judgement exists, the button of reopen will not display. So, skip the
judgement if the status of PR is closed.

![image](https://user-images.githubusercontent.com/33891828/222037529-651fccf9-0bba-433e-b2f0-79c17e0cc812.png)

3. Even if PR is already close, we should still insert comment record
into DB when we push commits.
So we should still call  function `CreatePushPullComment()`.

067b0c2664/services/pull/pull.go (L260-L282)
So, I add a switch(`includeClosed`) to the
`GetUnmergedPullRequestsByHeadInfo` func to control whether the status
of PR must be open. In this case, by setting `includeClosed` to `true`,
we can query the closed PR.

![image](https://user-images.githubusercontent.com/33891828/222621045-bb80987c-10c5-4eac-aa0c-1fb9c6aefb51.png)

4. In the loop of comments, I use the`latestCloseCommentID` variable to
record the last occurrence of the close comment.
In the go template, if the status of PR is closed, the comments whose
type is `CommentTypePullRequestPush(29)` after `latestCloseCommentID`
won't be rendered.


![image](https://user-images.githubusercontent.com/33891828/222058913-c91cf3e3-819b-40c5-8015-654b31eeccff.png)
e.g.
1). The initial status of the PR is opened.


![image](https://user-images.githubusercontent.com/33891828/222453617-33c5093e-f712-4cd6-8489-9f87e2075869.png)
2). Then I click the button of `Close`. PR is closed now.


![image](https://user-images.githubusercontent.com/33891828/222453694-25c588a9-c121-4897-9ae5-0b13cf33d20b.png)
3). I try to push a commit to this PR, even though its current status is
closed.


![image](https://user-images.githubusercontent.com/33891828/222453916-361678fb-7321-410d-9e37-5a26e8095638.png)
But in comments list, this commit do not display.This is as expected :)


![image](https://user-images.githubusercontent.com/33891828/222454169-7617a791-78d2-404e-be5e-77d555f93313.png)
4). Click the `Reopen` button, the commit which is pushed after closing
PR display now.


![image](https://user-images.githubusercontent.com/33891828/222454533-897893b6-b96e-4701-b5cb-b1800f382b8f.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-07 18:47:23 +08:00
Giteabot
6be6c19daf Fix PR view misalignment caused by long name file (#23321) (#23335)
Backport #23321

Close #23248

The UI after this PR:

https://user-images.githubusercontent.com/17645053/223009758-7f0c9f12-d346-4cb2-a605-729fddce732f.mov

Co-authored-by: Hester Gong <hestergong@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-07 11:11:55 +08:00
Giteabot
61f91bdc7e Update documentation for the new YAML label file format (#23020) (#23341)
Backport #23020

update documentation to include an overview of the yaml label template
that is part of PR #22976

Signed-off-by: Jon Roadley-Battin <jon.roadleybattin@gmail.com>

Co-authored-by: JonRB <4564448+eeyrjmr@users.noreply.github.com>
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2023-03-06 17:52:29 -06:00
Giteabot
8ab50be000 Remove unnecessary space on link (#23334) (#23340)
Backport #23334

The action run title has a blank. This PR removes it.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-06 16:35:51 -05:00
Giteabot
dfab6e2d1c Fix incorrect redirect link of delete org project (#23327) (#23339)
Backport #23327

A part of https://github.com/go-gitea/gitea/pull/22865/commits

The old code will cause 500 error.

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-03-06 16:05:42 -05:00
Giteabot
2f7bbdf8c9 Fix incorrect project links and use symlink icon for org-wide projects (#23325) (#23336)
Backport #23325

Fix displaying same projects icons between user/repo projects.
And fix incorrect projects links.
A part of https://github.com/go-gitea/gitea/pull/22865.


![image](https://user-images.githubusercontent.com/18380374/223044279-7b620ff1-d88a-4146-97e6-531bbf269761.png)

![image](https://user-images.githubusercontent.com/18380374/223044390-42911e3f-1f6b-439f-8441-4f3ebf99ea13.png)

![image](https://user-images.githubusercontent.com/18380374/223044437-5cad5391-0f95-4c8b-b0a3-32e263e2854f.png)

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-06 13:48:04 -06:00
Giteabot
af4767df5c Scoped labels: don't require holding alt key to remove (#23303) (#23331)
Backport #23303

Alt doesn't work on all browsers, the simplest solution for v1.19 is to
just not require it and toggle the label by just clicking.

Part of #22974

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-03-06 12:59:53 -06:00
Giteabot
233a399706 Fix broken code editor diff preview (#23307) (#23320)
Backport #23307

Close #23265, the code editor diff preview has been broken for long
time.

* Fix the regression for `data-line-num`
    * `.code-diff` is necessary to show the line number
* Fix the regression for #12434
* The diff:
[12434](https://github.com/go-gitea/gitea/pull/12434/files?diff=unified&w=1)
    * It hides the Type(4) (aka HunkHeader)  for unexpected cases.


Diff with ignoring whitespaces:
https://github.com/go-gitea/gitea/pull/23307/files?diff=unified&w=1

Before: see the issue #23265

After:


![image](https://user-images.githubusercontent.com/2114189/222942810-286dc9af-0b39-4e9d-8585-8c299b881241.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-03-06 12:05:35 -06:00
Giteabot
dcf1717793 Add context when rendering labels or emojis (#23281) (#23319)
Backport #23281

This branch continues the work of #23092 and attempts to rid the
codebase of any `nil` contexts when using a `RenderContext`.

Anything that renders markdown or does post processing may call
`markup.sha1CurrentPatternProcessor()`, and this runs
`git.OpenRepository()`, which needs a context. It will panic if the
context is `nil`. This branch attempts to _always_ include a context
when creating a `RenderContext` to prevent future crashes.

Co-authored-by: Jonathan Tran <jon@allspice.io>
2023-03-06 10:32:40 -06:00
Giteabot
b1e68f39e7 Properly flush unique queues on startup (#23154) (#23201)
Backport #23154

There have been a number of reports of PRs being blocked whilst being
checked which have been difficult to debug. In investigating #23050 I
have realised that whilst the Warn there is somewhat of a miscall there
was a real bug in the way that the LevelUniqueQueue was being restored
on start-up of the PersistableChannelUniqueQueue.

Next there is a conflict in the setting of the internal leveldb queue
name - This wasn't being set so it was being overridden by other unique
queues.

This PR fixes these bugs and adds a testcase.

Thanks to @brechtvl  for noticing the second issue.

Fix #23050
and others

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <leon@kske.dev>
2023-03-06 22:35:07 +08:00
Giteabot
ee3d9330a8 Update hacking-on-gitea-zh_cn documentation (#23315) (#23323)
Backport #23315

This PR fix outdated hacking-on-gitea-zh_cn documentation.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
2023-03-06 18:44:02 +08:00
Giteabot
d1d15306d1 Change interactiveBorder to fix popup preview (#23169) (#23314)
Backport #23169

Close #23073. 
Used the solution as reference to the reply:
https://github.com/go-gitea/gitea/issues/23073#issuecomment-1440124609
Here made the change inside the `contextpopup.js` because this is where
the popup component is created and tippy configuration is given.

Co-authored-by: Hester Gong <hestergong@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-06 16:45:43 +08:00
Giteabot
e3b1ebbbfe Scoped labels: set aria-disabled on muted Exclusive option for a11y (#23306) (#23311)
Backport #23306

It is convenient to be able to toggle off this option after removing /
from the name. This ensures the muted state is communicated to blind
users even when the input is not fully disabled.

Part of #22974

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-05 23:05:11 +08:00
Giteabot
17ae7e335e Add basic documentation for labels, including scoped labels (#23304) (#23309)
Backport #23304

Part of #22974

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: delvh <dev.lh@web.de>
2023-03-05 20:38:46 +08:00
Giteabot
1edb57eda9 Fix various bugs for "install" page (#23194) (#23286)
Backport #23194

## TLDR

* Fix the broken page / broken image problem when click "Install"
* Fix the Password Hash Algorithm display problem for #22942
* Close #20089
* Close #23183
* Close #23184

## Details

### The broken page / broken image problem when clicking on "Install"
(Redirect failed after install - #23184)

Before: when clicking on "install", all new requests will fail, because the
server has been restarted. Users just see a broken page with broken
images, sometimes the server is not ready but the user would have been
redirect to "/user/login" page, then the users see a new broken page
(connection refused or something wrong ...)


After: only check InstallLock=true for necessary handlers, and sleep for
a while before restarting the server, then the browser has enough time
to load the "post-install" page. And there is a script to check whether
"/user/login" is ready, the user will only be redirected to the login
page when the server is ready.

### During new instance setup fill 'Gitea Base URL' with
window.location.origin - #20089

If the "app_url" input contains `localhost` (the default value from
config), use current window's location href as the `app_url` (aka
ROOT_URL)


### Fix the Password Hash Algorithm display problem for "Provide the
ability to set password hash algorithm parameters #22942"

Before: the UI shows `pbkdf2$50000$50`

<details>


![image](https://user-images.githubusercontent.com/2114189/221917143-e1e54798-1698-4fee-a18d-00c48081fc39.png)

</details>

After: the UI shows `pbkdf2`

<details>


![image](https://user-images.githubusercontent.com/2114189/221916999-97a15be8-2ebb-4a01-bf93-dac18e354fcc.png)

</details>



### GET data: net::ERR_INVALID_URL #23183

Cause by empty `data:` in `<link rel="manifest"
href="data:{{.ManifestData}}">`

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-05 11:59:58 +01:00
Giteabot
a2a9b0f977 Support sanitising the URL by removing extra slashes in the URL (#21333) (#23300)
Backport #21333

Changes in this PR :

Strips incoming request URL of additional slashes (/). For example an
input like

`https://git.data.coop//halfd/new-website.git` is translated to
`https://git.data.coop/halfd/new-website.git`

Fixes https://github.com/go-gitea/gitea/issues/20462

Fix #23242

Co-authored-by: Sandeep Bhat <sandyethadka@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
2023-03-05 02:14:12 -05:00
Giteabot
ff96f804b6 update to mermaid v10 (#23178) (#23299)
Backport #23178

fix #23153

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: delvh <leon@kske.dev>
2023-03-05 02:13:50 -05:00
Giteabot
a926994bfe Re-add accidentally removed hacking-on-gitea.zh-cn.md (#23297) (#23305) 2023-03-04 20:09:58 -05:00
Giteabot
83903535e3 Fix code wrap for unbroken lines (#23268) (#23293)
Backport #23268

## The Problem

`overflow-wrap: break-word` doesn't work well for unbroken lines. Use
`overflow-wrap: anywhere` instead, and remove legacy alias `word-wrap`

## Before


![image](https://user-images.githubusercontent.com/2114189222743939-5f38d9e4-18d8-4ae0-8078-4b3a59195a30.png)

## After


![image](https://user-images.githubusercontent.com/2114189/222743833-0e0cfdbb-7b2e-420d-99f9-b1b45dde521a.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-03-04 20:55:12 +01:00
Giteabot
8142408d3a Fill head commit to in payload when notifying push commits for mirroring (#23215) (#23292)
Backport #23215

Just like what has been done when pushing manually:

7a5af25592/services/repository/push.go (L225-L226)

Before:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100123-cd4839d1-2d4d-45f7-7a0-0cbc73162b44.png">

After:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100225-3c5bb65-7ab9-41e2-8e39-9d84c23c352d.png">

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-04 19:02:50 +01:00
Giteabot
a4158d1904 Avoid panic caused by broken payload when creating commit status (#23216) (#23294)
Backport #23216

When creating commit status for Actons jobs, a payload with nil
`HeadCommit` will cause panic.

Reported at:
https://gitea.com/gitea/act_runner/issues/28#issuecomment-732166

Although the `HeadCommit` probably can not be nil after #23215,
`CreateCommitStatus` should protect itself, to avoid being broken in the
future.

In addition, it's enough to print error log instead of returning err
when `CreateCommitStatus` failed.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: delvh <dev.lh@web.de>
2023-03-04 14:23:49 +00:00
Giteabot
781019216c Fix GetFilesChangedBetween if the file name may be escaped (#23272) (#23279)
Backport #23272

The code for GetFilesChangedBetween uses `git diff --name-only
base..head` to get the names of files changed between base and head
however this forgets that git will escape certain values.

This PR simply switches to use `-z` which has the `NUL` character as the
separator.

Ref https://github.com/go-gitea/gitea/pull/22568#discussion_r1123138096

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-04 00:38:31 -05:00
Giteabot
1322cd7a58 Use correct README link to render the README (#23152) (#23264)
Backport #23152

`renderReadmeFile` needs `readmeTreelink` as parameter but gets
`treeLink`.
The values of them look like as following:
`treeLink`:  `/{OwnerName}/{RepoName}/src/branch/{BranchName}`
`readmeTreelink`:
`/{OwnerName}/{RepoName}/src/branch/{BranchName}/{ReadmeFileName}`

`path.Dir` in

8540fc45b1/routers/web/repo/view.go (L316)
should convert `readmeTreelink` into
`/{OwnerName}/{RepoName}/src/branch/{BranchName}` instead of the current
`/{OwnerName}/{RepoName}/src/branch`.

Fixes #23151

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-03-04 00:38:11 -05:00
Giteabot
464bbd747e Fix commit retrieval by tag (#21804) (#23266)
Backport #21804

It is not correct to return tag data when commit data is requested, so
remove the hacky code that overwrote parts of a commit with parts of a
tag.

This fixes commit retrieval by tag for both the latest commit in the UI
and the commit info on tag webhook events.

Fixes: https://github.com/go-gitea/gitea/issues/21687
Replaces: https://github.com/go-gitea/gitea/pull/21693

<img width="324" alt="Screenshot 2022-11-13 at 15 26 37"
src="https://user-images.githubusercontent.com/115237/201526975-736c6ea7-ad6a-467a-a823-9a63d6ecb718.png">

<img width="789" alt="image"
src="https://user-images.githubusercontent.com/115237/201526876-90a13ffc-1e5c-4d76-911b-f1ae51e8eaab.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-03 13:42:46 -06:00
Giteabot
574182e1eb Revert relative links to absolute links in mail templates (#23267) (#23269)
Backport #23267

Follow #21986 , fix regression.

The mail templates should always use `AppURL` (the full absolute URL)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-03-03 17:41:00 +00:00
Giteabot
ef8209a953 Use async await to fix empty quote reply at first time (#23168) (#23256)
Backport #23168

The reason why quote reply is empty is when quote reply is clicked, it
triggers the click function on `.comment-form-reply` button, and when
the first time this function is triggered, easyMDE for the reply has not
yet initialized, so that click handler of `.quote-reply` button in
`repo-legacy.js` got an `undefined` as easyMDE, and the following lines
which put quoted reply into the easyMDE is not executed.
The workaround in this PR is to pass the replied content to
'.comment-form-reply' button if easyMDE is not yet initialized (quote
reply first clicked) and put the replied content into it the after
easyMDE is created.
Now quote reply on first click:


https://user-images.githubusercontent.com/17645053/221452823-fc699d50-1649-4af1-952e-f04fc8d2978e.mov

<br />


Update:
The above change is not appropriate as stated in the
[comment](https://github.com/go-gitea/gitea/pull/23168#issuecomment-1445562284)
Use await instead

Close #22075.
Close #23247.

Co-authored-by: HesterG <hestergong@gmail.com>
2023-03-02 16:36:21 -06:00
Giteabot
9309098eab Fix switched citation format (#23250) (#23253)
Backport #23250

Due to switched input parameters, the citation texts for Bibtex and Apa
were switched.
This pull request fixes #23244

Co-authored-by: Blender Defender <contact.blenderdefender@gmail.com>
2023-03-02 14:05:10 -06:00
Giteabot
790a79b04c Fix missed .hide class (#23208) (#23237)
Backport #23208

https://github.com/go-gitea/gitea/pull/22950 removed `hide` class, and
use `gt-hidden`
But there are some missed `hide`....

Co-authored-by: yp05327 <576951401@qq.com>
2023-03-02 11:45:42 -06:00
Giteabot
f8a40dafb9 Allow <video> in MarkDown (#22892) (#23236)
Backport #22892

As you can imagine, for the Blender development process it is rather
nice to be able to include videos in issues, pull requests, etc.

This PR allows the `<video>` HTML tag to be used in MarkDown, with the
`src`, `autoplay`, and `controls` attributes.

## Help Needed

To have this fully functional, personally I feel the following things
are still missing, and would appreciate some help from the Gitea team.

### Styling

Some CSS is needed, but I couldn't figure out which of the LESS files
would work. I tried `web_src/less/markup/content.less` and
`web_src/less/_base.less`, but after running `make` the changes weren't
seen in the frontend.

This I would consider a minimal set of CSS rules to be applied:

```css
video {
  max-width: 100%;
  max-height: 100vh;
}
```

### Default Attributes

It would be fantastic if Gitea could add some default attributes to the
`<video>` tag. Basically `controls` should always be there, as there is
no point in disallowing scrolling through videos, looping them, etc.

### Integration with the attachments system

Another thing that could be added, but probably should be done in a
separate PR, is the integration with the attachments system. Dragging in
a video should attach it, then generate the appropriate MarkDown/HTML.

Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
2023-03-02 11:49:05 -05:00
Giteabot
9843a0b741 Close the temp file when dumping database to make the temp file can be deleted on Windows (#23249) (#23251)
Backport #23249

There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-03-02 11:47:07 -05:00
Giteabot
085a4debd5 Fix incorrect checkbox behaviors in the dashboard repolist's filter (#23147) (#23205)
Backport #23147

Co-author: yp05327 , this PR is based on yp05327's #22813.

The problems of the old DashboardRepoList / repolist.tmpl: 

* It mixes many different frameworks together
* It "just works", bug on bug
* It uses many anti-pattern of Vue

This PR:

* Fix bugs and close #22800
* Decouple the "checkbox" elements from Fomantic UI (only use CSS
styles)
* Simplify the HTML layout
* Simplify JS logic
* Make it easier to refactor the DashboardRepoList into a pure Vue
component in the future.

### Screenshots

#### Default

![image](https://user-images.githubusercontent.com/2114189/221355768-a3eb5b23-85b4-4e3d-b906-844d8b15539d.png)

####  Click "Archived" to make it checked

![image](https://user-images.githubusercontent.com/2114189/221355777-9a104ddf-52a7-4504-869a-43a73827d802.png)

####  Click "Archived" to make it intermediate

![image](https://user-images.githubusercontent.com/2114189/221355802-0f67a073-67ad-4e92-84a6-558c432103a5.png)

####  Click "Archived" to make it unchecked

![image](https://user-images.githubusercontent.com/2114189/221355810-acf1d9d8-ccce-47fe-a02e-70cf4e666331.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-02 15:12:33 +08:00
Giteabot
4c1e24864f Order pull request conflict checking by recently updated, for each push (#23220) (#23225)
Backport #23220

When a change is pushed to the default branch and many pull requests are
open for that branch, conflict checking can take some time.

Previously it would go from oldest to newest pull request. Now
prioritize pull requests that are likely being actively worked on or
prepared for merging.

This only changes the order within one push to one repository, but the
change is trivial and can already be quite helpful for smaller Gitea
instances where a few repositories have most pull requests. A global
order would require deeper changes to queues.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-02 13:12:41 +08:00
Giteabot
5d5f907e7f Add loading yaml label template files (#22976) (#23232)
Backport #22976

Extract from #11669 and enhancement to #22585 to support exclusive
scoped labels in label templates

* Move label template functionality to label module
* Fix handling of color codes
* Add Advanced label template

Co-authored-by: Lauris BH <lauris@nix.lv>
2023-03-01 21:57:34 -05:00
Giteabot
39178b5756 Do not create commit graph for temporary repos (#23219) (#23229)
Backport #23219

When fetching remotes for conflict checking, skip unnecessary and
potentially slow writing of commit graphs.

In a test with the Blender repository, this reduces conflict checking
time for one pull request from about 2s to 0.1s.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-03-02 01:53:41 +02:00
Giteabot
3d8412dd51 Use the correct selector to hide the checkmark of selected labels on clear (#23224) (#23228)
Backport #23224

Regression of #10107
(https://github.com/go-gitea/gitea/pull/10107/files#diff-a15e36f2f9c13339f7fdd38bc2887db2ff2945cb8434464318ab9105fcc846bdR460)

Fix #22222


Before: the "clear" action couldn't remove these check marks.


![image](https://user-images.githubusercontent.com/2114189/222212998-c9f33459-b71d-4e80-8588-2935f3b7050c.png)


After: the "clear" action can remove these  check marks.


![image](https://user-images.githubusercontent.com/2114189/222213048-2be98ed0-cac0-4e27-b72c-1dd0ac2637d5.png)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-03-01 15:59:36 -05:00
Yarden Shoham
ff7057a46d Change button text for commenting and closing an issue at the same time (#23135) (#23182)
Backport #23135

Close  #10468

Without SimpleMDE/EasyMDE, using Simple Textarea, the button text could
be changed when content changes.

After introducing SimpleMDE/EasyMDE, there is no code for updating the
button text.



![image](https://user-images.githubusercontent.com/2114189/221334034-8d556cd5-1136-4ba0-8faa-a65ffadd7fb7.png)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-02-28 17:54:24 -05:00
wxiaoguang
bb8ef28913 Fix Fomantic UI's touchstart fastclick, always use click for click events (#23065) (#23195)
Backport #23065

Using `touchstart` for `click` events is a black magic for mobile
browsers (Google: `fastclick`).

However, it causes many UX problems if the fastclick is used without
careful design.

Fomantic UI uses this fastclick for its `dimmer` and `dropdown`, it
makes mobile users feel strange when they "touch" the dropdown menu.


This PR uses a simple patch to fix that behavior. Then the Fomantic
dropdown only uses `click` for click events.

This PR is simple enough and won't cause hidden bugs even if the patch
doesn't work. In the future, if there are more patches for Fomantic UI,
the patches could be placed in a directory like
`web_src/fomantic/patches/001-fix-click-touchstart`, etc.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-28 17:53:45 -05:00
Giteabot
13918ad344 Pass --global when calling git config --get, for consistency with git config --set (#23157) (#23199)
Backport #23157

This arose out of #22451; it seems we are checking using non-global
settings to see if a config value is set, in order to decide whether to
call another global(-indeed) configuration command. This PR changes it
so that both the check and the set are for global configuration.

Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
2023-02-28 17:53:15 -05:00
Giteabot
7528ce60e7 Make gitea serv respect git binary home (#23138) (#23197)
Backport #23138

Close #23137

The old code is too old (8-9 years ago)

Let's try to execute the git commands from git bin home directly.

The verb has been checked above, it could only be:
* git-upload-pack
* git-upload-archive
* git-receive-pack
* git-lfs-authenticate

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-02-28 16:46:23 -06:00
Yarden Shoham
6c6a7e7d97 Avoid too long names for actions (#23162) (#23190)
Backport #23162

The name of the job or step comes from the workflow file, while the name
of the runner comes from its registration. If the strings used for these
names are too long, they could cause db issues.

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-28 13:42:40 +01:00
Yarden Shoham
111c509287 Add InsecureSkipVerify to Minio Client for Storage (#23166) (#23177)
Backport #23166

Allows using Minio with untrusted certificates

Closes #23128

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-28 00:29:17 +02:00
Yarden Shoham
9d7ef0ad63 Add word-break to sidebar-item-link (#23146) (#23180)
Backport #23146

Fixes https://github.com/go-gitea/gitea/issues/22953

![image](https://user-images.githubusercontent.com/18380374/221351117-1e4b8922-04ca-4717-8e3b-c338a61bc062.png)

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: delvh <leon@kske.dev>
2023-02-27 15:59:36 -05:00
Yarden Shoham
9aae54c81f Remove useless comment in #23114 (#23173) (#23175)
Backport #23173

The `isAdmin` param is no longer used so the comment should be removed.

d27d36f2f4/routers/web/explore/repo.go (L36-L37)

Co-authored-by: Zettat123 <zettat123@gmail.com>
2023-02-27 22:43:15 +08:00
Yarden Shoham
1bc4ffc337 Return 404 instead of 403 if user can not access the repo (#23155) (#23158)
Backport #23155

Fixes https://github.com/go-gitea/gitea/issues/23150

Before:

![image](https://user-images.githubusercontent.com/18380374/221390802-2317c6bc-d163-4def-b68b-6bb297143fe2.png)

After:

![image](https://user-images.githubusercontent.com/18380374/221390823-87490351-39c3-4a40-b1d2-11fc5b85fa24.png)

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-26 20:20:44 +08:00
Yarden Shoham
27879bc45e Fix DBConsistency checks on MSSQL (#23132) (#23134)
Backport #23132

Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2023-02-25 23:25:58 +08:00
Yarden Shoham
a3694b6989 Fix secrets overview page missing from docs sidebar (#23143) (#23145)
Backport #23143

There was a warning while building the docs: `Building sites … WARN
2023/02/25 08:56:37
"/workspace/gitea/docs/content/doc/secrets/overview.en-us.md:1:1":
duplicate menu entry with identifier "overview" in menu "sidebar"`.

### Before

![image](https://user-images.githubusercontent.com/20454870/221348741-55cef254-f2ac-4507-9a66-818b406c668f.png)

### After

![image](https://user-images.githubusercontent.com/20454870/221348757-42066303-e1b7-43fe-9c4f-e05182fbabdd.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-25 13:30:32 +02:00
Yarden Shoham
28625fba5b Redirect to the commit page after applying patch (#23056) (#23127)
Backport #23056

Fixes https://github.com/go-gitea/gitea/issues/22621

Co-authored-by: yp05327 <576951401@qq.com>
2023-02-24 22:43:26 -05:00
Yarden Shoham
7c3196ceac Avoid warning for system setting when start up (#23054) (#23116)
Backport #23054

Partially fix #23050

After #22294 merged, it always has a warning log like `cannot get
context cache` when starting up. This should not affect any real life
but it's annoying. This PR will fix the problem. That means when
starting up, getting the system settings will not try from the cache but
will read from the database directly.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-24 16:46:11 -05:00
Yarden Shoham
80c1264f4b Show empty repos in Admin Repository Management page (#23114) (#23130)
Backport #23114

The **Admin Repository Management** page and the **Explore Repository**
page both use the `RenderRepoSearch` function. In this function, the
`OnlyShowRelevant` search option is `true` when querying repositories
for admin page.


edf98a2dc3/routers/web/explore/repo.go (L99-L115)

Refer to
[#19361](https://github.com/go-gitea/gitea/pull/19361/files#diff-8058dfb85557010e0592d586675ec62ce406af7068e6311f39c160deac37f149R497),
the repositories with `is_empty=true` will be hidden if
`OnlyShowRelevant` is `true`.

Administrators should be able to see all repositories. So
`OnlyShowRelevant` shouldn't be set to `true` .

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2023-02-24 20:17:21 +00:00
silverwind
f0340c28f1 Change style to improve whitespaces trimming inside inline markdown code (#23093) (#23120)
Backport #23093

Given mardown source
```
x ` a` y
x `a ` y
x ` a ` y
```

Render

<img width="1421" alt="2023-02-23 15 33 14"

src="https://user-images.githubusercontent.com/17645053/220844280-a304c788-ac79-4a26-a55a-0db00f2fb3f3.png">

Fixes #23080.

Co-authored-by: HesterG <hestergong@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 17:05:36 +00:00
Yarden Shoham
5beb29ad35 Fix height for sticky head on large screen on PR page (#23111) (#23123)
Backport #23111

Right now on the PR 'File Change' Tab, the file title header sticky to
the top on large screens has wrong height, resulting in wrong ui
behavior when scrolling down. This PR is to fix this.

Before:

<img width="964" alt="截屏2023-02-24 17 12 29"
src="https://user-images.githubusercontent.com/17645053/221140409-025c4a84-6bbe-4b5b-a13f-bd2b79063522.png">

After:
<img width="1430" alt="截屏2023-02-24 21 10 12"
src="https://user-images.githubusercontent.com/17645053/221186750-0344d652-4610-4a90-a4c0-7f6269f950d6.png">

Co-authored-by: HesterG <hestergong@gmail.com>
2023-02-24 14:47:48 +00:00
Yarden Shoham
27e307142b Fix db.Find bug (#23115) (#23119)
Backport #23115

Caused by #20821 

Fix #23110
2023-02-24 14:05:36 +00:00
Yarden Shoham
e02e752f68 Fix nil context in RenderMarkdownToHtml (#23092) (#23108)
Backport #23092

Fix #23082.

This bug is caused by a nil context in
https://github.com/go-gitea/gitea/issues/23082#issuecomment-1441276546 .

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 21:17:03 +08:00
Yarden Shoham
5ddf67a9c2 Make issue meta dropdown support Enter, confirm before reloading (#23014) (#23102)
Backport #23014

As the title. Label/assignee share the same code.

* Close #22607
* Close #20727

Also:

* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329

### The `Enter` support

Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.

After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)


This is only a quick patch, the UX is still not perfect, but it's much
better than before.


### The `confirm` before reloading

And more fixes for the `reload` problem, the new behaviors:

* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.

That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.

Screenshot of the confirm dialog:

<details>


![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)

</details>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 17:40:36 +08:00
Yarden Shoham
4d3e2b23b8 Fix SyncOnCommit always return false in API of push_mirrors (#23088) (#23100)
Backport #23088

Fix: #22990

---
Before, the return value of the api is always false,regrardless of
whether the entry of `sync_on_commit` is true or false.
I have confirmed that the value of `sync_on_commit` dropped into the
database is correct.
So, I think it is enough to make some small changes.

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 14:36:25 +08:00
Yarden Shoham
ddf61373f6 Add wrapper to author to avoid long name ui problem (#23030) (#23098)
Backport #23030

This PR is a possible solution for issue #22866. Main change is to add a
`author-wrapper` class around author name, like the wrapper added to
message. The `max-width` is set to 200px on PC, and 100px on mobile
device for now. Which will work like below:

<img width="1183" alt="2023-02-21 11 57 53"
src="https://user-images.githubusercontent.com/17645053/220244146-3d47c512-33b6-4ed8-938e-de0a8bc26ffb.png">

<img width="417" alt="2023-02-21 11 58 43"
src="https://user-images.githubusercontent.com/17645053/220244154-1ea0476b-9d1c-473a-9917-d3216860f9a9.png">

And `title` is added to the wrapper like it did in message wrapper. So
the full author name will show on hover.

Co-authored-by: HesterG <hestergong@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 10:45:18 +08:00
Yarden Shoham
b4ed3f07e4 Fix commit name in Apply Patch page (#23086) (#23099)
Backport #23086

Fixes
https://github.com/go-gitea/gitea/issues/22621#issuecomment-1439309200

Co-authored-by: yp05327 <576951401@qq.com>
2023-02-24 08:47:35 +08:00
HesterG
ced94f2e0d Add accessibility to the menu on the navbar (#23059) (#23095)
Backport #23059

This PR is trying to add accessibility to the menu as mentioned in
#23053 so the menu can be accessed using keyboard (A quick demo is added
below), with a reference to
[PR2612](https://github.com/go-gitea/gitea/pull/22612). The goal is to
make the menu accessible merely using keyboard like shown below. And
this PR might need confirmation from developers using screen readers.
2023-02-23 20:56:03 +08:00
Yarden Shoham
aff432b197 Nest metadata in refactoring docs (#23087) (#23091)
Backport #23087

Whitespace was missing from refactoring docs metadata.

backport label applied so it is included in versioned docs.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-23 03:39:30 -05:00
Yarden Shoham
0ac3be1482 Improve accessibility for issue comments (#22612) (#23083)
Backport #22612

### Preamble

Gitea is an extremely great and smart solution perfectly suitable for
smaller systems and self-hosted Git-powered setups. However, there is a
group of people who have indredible difficulties in using Gitea,
rendering it useless in many cases. Those people are blind developers
using [screen readers](https://en.wikipedia.org/wiki/Screen_reader).
Unfortunately, the frontend framework is super convoluted, and Go
templates don’t allow accessibility improvements in a straightforward
way. As a blind developer myself, I'm trying to start fixing smaller
accessibility quirks with intention to go deeper and eventually, alone
or not, make Gitea at least mostly accessible for screen reader users.

### What This Fix Does

My blind fellows and me navigate webpages not very similarly to how a
sighted person does it. For instance, we love semantic HTML markup like
headings, lists, tables etc. because our screen readers allow us to jump
by those landmarks with a single keypress.
Currently in Gitea issue comments are not marked up with headings. I'm
trying to fix this by adding an appropriate
[ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) role for
comment header and also by enclosing the comment itself in a semantical
article element.

Co-authored-by: Andre Polykanine <ap@oire.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-23 16:32:15 +08:00
Yarden Shoham
75eaf99076 Wrap unless-check in docker manifests (#23079) (#23081)
Backport #23079

Should fix the following:
> failed to render template: Evaluation error: Helper 'unless' called
with wrong number of arguments, needed 2 but got 3

https://go.dev/play/p/h7bt7MWKTcv

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-23 01:34:47 +01:00
wxiaoguang
e67d60d336 Fix some more hidden problems (#23074) (#23075)
Backport #23074
2023-02-22 15:26:48 +00:00
355 changed files with 13036 additions and 6248 deletions

View File

@@ -43,7 +43,7 @@ steps:
depends_on: [deps-frontend] depends_on: [deps-frontend]
- name: lint-backend - name: lint-backend
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
pull: always pull: always
commands: commands:
- make lint-backend - make lint-backend
@@ -57,7 +57,7 @@ steps:
path: /go path: /go
- name: lint-backend-windows - name: lint-backend-windows
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
commands: commands:
- make golangci-lint-windows vet - make golangci-lint-windows vet
environment: environment:
@@ -72,7 +72,7 @@ steps:
path: /go path: /go
- name: lint-backend-gogit - name: lint-backend-gogit
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
commands: commands:
- make lint-backend - make lint-backend
environment: environment:
@@ -264,13 +264,13 @@ steps:
- git update-ref refs/heads/tag_test ${DRONE_COMMIT_SHA} - git update-ref refs/heads/tag_test ${DRONE_COMMIT_SHA}
- name: prepare-test-env - name: prepare-test-env
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
pull: always pull: always
commands: commands:
- ./build/test-env-prepare.sh - ./build/test-env-prepare.sh
- name: build - name: build
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- ./build/test-env-check.sh - ./build/test-env-check.sh
@@ -285,7 +285,7 @@ steps:
path: /go path: /go
- name: unit-test - name: unit-test
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- make unit-test-coverage test-check - make unit-test-coverage test-check
@@ -301,7 +301,7 @@ steps:
path: /go path: /go
- name: unit-test-gogit - name: unit-test-gogit
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- make unit-test-coverage test-check - make unit-test-coverage test-check
@@ -317,7 +317,7 @@ steps:
path: /go path: /go
- name: test-mysql - name: test-mysql
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- make test-mysql-migration integration-test-coverage - make test-mysql-migration integration-test-coverage
@@ -334,7 +334,7 @@ steps:
path: /go path: /go
- name: test-mysql8 - name: test-mysql8
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- timeout -s ABRT 50m make test-mysql8-migration test-mysql8 - timeout -s ABRT 50m make test-mysql8-migration test-mysql8
@@ -350,7 +350,7 @@ steps:
path: /go path: /go
- name: test-mssql - name: test-mssql
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-amd64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- make test-mssql-migration test-mssql - make test-mssql-migration test-mssql
@@ -454,13 +454,13 @@ steps:
path: /go path: /go
- name: prepare-test-env - name: prepare-test-env
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-arm64 # https://gitea.com/gitea/test-env
pull: always pull: always
commands: commands:
- ./build/test-env-prepare.sh - ./build/test-env-prepare.sh
- name: build - name: build
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-arm64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- ./build/test-env-check.sh - ./build/test-env-check.sh
@@ -475,7 +475,7 @@ steps:
path: /go path: /go
- name: test-sqlite - name: test-sqlite
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-arm64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- timeout -s ABRT 50m make test-sqlite-migration test-sqlite - timeout -s ABRT 50m make test-sqlite-migration test-sqlite
@@ -491,7 +491,7 @@ steps:
path: /go path: /go
- name: test-pgsql - name: test-pgsql
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env image: gitea/test_env:linux-1.19-arm64 # https://gitea.com/gitea/test-env
user: gitea user: gitea
commands: commands:
- timeout -s ABRT 50m make test-pgsql-migration test-pgsql - timeout -s ABRT 50m make test-pgsql-migration test-pgsql
@@ -1016,7 +1016,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: true auto_tag: true
@@ -1028,13 +1028,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: true auto_tag: true
@@ -1046,6 +1050,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1080,7 +1088,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
tags: ${DRONE_TAG##v}-linux-amd64 tags: ${DRONE_TAG##v}-linux-amd64
@@ -1091,13 +1099,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
tags: ${DRONE_TAG##v}-linux-amd64-rootless tags: ${DRONE_TAG##v}-linux-amd64-rootless
@@ -1108,6 +1120,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1142,7 +1158,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: false auto_tag: false
@@ -1154,13 +1170,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: false auto_tag: false
@@ -1172,6 +1192,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1205,7 +1229,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: false auto_tag: false
@@ -1217,13 +1241,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: false auto_tag: false
@@ -1235,6 +1263,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1243,7 +1275,7 @@ steps:
--- ---
kind: pipeline kind: pipeline
type: docker type: docker
name: docker-linux-arm64-dry-run name: docker-linux-amd64-dry-run
platform: platform:
os: linux os: linux
@@ -1261,7 +1293,7 @@ trigger:
steps: steps:
- name: dryrun - name: dryrun
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
dry_run: true dry_run: true
@@ -1272,6 +1304,7 @@ steps:
environment: environment:
PLUGIN_MIRROR: PLUGIN_MIRROR:
from_secret: plugin_mirror from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
- pull_request - pull_request
@@ -1308,7 +1341,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: true auto_tag: true
@@ -1320,13 +1353,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: true auto_tag: true
@@ -1338,6 +1375,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1372,7 +1413,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
tags: ${DRONE_TAG##v}-linux-arm64 tags: ${DRONE_TAG##v}-linux-arm64
@@ -1383,13 +1424,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
tags: ${DRONE_TAG##v}-linux-arm64-rootless tags: ${DRONE_TAG##v}-linux-arm64-rootless
@@ -1400,6 +1445,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1434,7 +1483,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: false auto_tag: false
@@ -1446,13 +1495,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: false auto_tag: false
@@ -1464,6 +1517,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
@@ -1497,7 +1554,7 @@ steps:
- git fetch --tags --force - git fetch --tags --force
- name: publish - name: publish
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
pull: always pull: always
settings: settings:
auto_tag: false auto_tag: false
@@ -1509,13 +1566,17 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:
- pull_request - pull_request
- name: publish-rootless - name: publish-rootless
image: techknowlogick/drone-docker:latest image: plugins/docker:latest
settings: settings:
dockerfile: Dockerfile.rootless dockerfile: Dockerfile.rootless
auto_tag: false auto_tag: false
@@ -1527,6 +1588,10 @@ steps:
from_secret: docker_password from_secret: docker_password
username: username:
from_secret: docker_username from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
DOCKER_BUILDKIT: 1
when: when:
event: event:
exclude: exclude:

View File

@@ -1,12 +1,16 @@
plugins: plugins:
- stylelint-declaration-strict-value - stylelint-declaration-strict-value
ignoreFiles:
- "**/*.go"
overrides: overrides:
- files: ["**/*.less"]
customSyntax: postcss-less
- files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"] - files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"]
rules: rules:
scale-unlimited/declaration-strict-value: null scale-unlimited/declaration-strict-value: null
- files: ["**/chroma/*", "**/codemirror/*"]
rules:
block-no-empty: null
rules: rules:
alpha-value-notation: null alpha-value-notation: null

View File

@@ -4,6 +4,356 @@ This changelog goes through all the changes that have been made in each release
without substantial changes to our git log; to see the highlights of what has without substantial changes to our git log; to see the highlights of what has
been added to each release, please refer to the [blog](https://blog.gitea.io). been added to each release, please refer to the [blog](https://blog.gitea.io).
## [1.19.0](https://github.com/go-gitea/gitea/releases/tag/1.19.0) - 2023-03-19
* BREAKING
* Add loading yaml label template files (#22976) (#23232)
* Make issue and code search support camel case for Bleve (#22829)
* Repositories: by default disable all units except code and pulls on forks (#22541)
* Support template for merge message description (#22248)
* Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
* Implement actions (#21937)
* Remove deprecated DSA host key from Docker Container (#21522)
* Improve valid user name check (#20136)
* SECURITY
* Return 404 instead of 403 if user can not access the repo (#23155) (#23158)
* Support scoped access tokens (#20908)
* FEATURES
* Add support for commit cross references (#22645)
* Scoped labels (#22585)
* Add Chef package registry (#22554)
* Support asciicast files as new markup (#22448)
* cgo cross-compile for freebsd (#22397)
* Add cron method to gc LFS MetaObjects (#22385)
* Add new captcha: cloudflare turnstile (#22369)
* Enable `@<user>`- completion popup on the release description textarea (#22359)
* make /{username}.png redirect to user/org avatar (#22356)
* Add Conda package registry (#22262)
* Support org/user level projects (#22235)
* Add Mermaid copy button (#22225)
* Add user secrets (#22191)
* Secrets storage with SecretKey encrypted (#22142)
* Preview images for Issue cards in Project Board view (#22112)
* Add support for incoming emails (#22056)
* Add Cargo package registry (#21888)
* Add option to prohibit fork if user reached maximum limit of repositories (#21848)
* Add attention blocks within quote blocks for `Note` and `Warning` (#21711)
* Add Feed for Releases and Tags (#21696)
* Add package registry cleanup rules (#21658)
* Add "Copy" button to file view of raw text (#21629)
* Allow disable sitemap (#21617)
* Add package registry quota limits (#21584)
* Map OIDC groups to Orgs/Teams (#21441)
* Keep languages defined in .gitattributes (#21403)
* Add Webhook authorization header (#20926)
* Supports wildcard protected branch (#20825)
* Copy citation file content, in APA and BibTex format, on repo home page (#19999)
* API
* Match api migration behavior to web behavior (#23552) (#23573)
* Purge API comment (#23451) (#23452)
* User creation API: allow custom "created" timestamps (#22549)
* Add `updated_at` field to PullReview API object (#21812)
* Add API management for issue/pull and comment attachments (#21783)
* Add API endpoint to get latest release (#21267)
* Support system hook API (#14537)
* ENHANCEMENTS
* Add `.patch` to `attachment.ALLOWED_TYPES` (#23580) (#23582)
* Fix sticky header in diff view (#23554) (#23568)
* Refactor merge/update git command calls (#23366) (#23544)
* Fix review comment context menu clipped bug (#23523) (#23543)
* Imrove scroll behavior to hash issuecomment(scroll position, auto expand if file is folded, and on refreshing) (#23513) (#23540)
* Increase horizontal page padding (#23507) (#23537)
* Use octicon-verified for gpg signatures (#23529) (#23536)
* Make time tooltips interactive (#23526) (#23527)
* Replace Less with CSS (#23508)
* Fix 'View File' button in code search (#23478) (#23483)
* Convert GitHub event on actions and fix some pull_request events. (#23037) (#23471)
* Support reflogs (#22451) (#23438)
* Fix actions frontend bugs (pagination, long name alignment) and small simplify (#23370) (#23436)
* Scoped label display and documentation tweaks (#23430) (#23433)
* Add missing tabs to org projects page (#22705) (#23412)
* Fix and move "Use this template" button (#23398) (#23408)
* Handle OpenID discovery URL errors a little nicer when creating/editing sources (#23397) (#23403)
* Rename `canWriteUnit` to `canWriteProjects` (#23386) (#23399)
* Refactor and tidy-up the merge/update branch code (#22568) (#23365)
* Refactor `setting.Database.UseXXX` to methods (#23354) (#23356)
* Fix incorrect project links and use symlink icon for org-wide projects (#23325) (#23336)
* Fix PR view misalignment caused by long name file (#23321) (#23335)
* Scoped labels: don't require holding alt key to remove (#23303) (#23331)
* Add context when rendering labels or emojis (#23281) (#23319)
* Change interactiveBorder to fix popup preview (#23169) (#23314)
* Scoped labels: set aria-disabled on muted Exclusive option for a11y (#23306) (#23311)
* update to mermaid v10 (#23178) (#23299)
* Fix code wrap for unbroken lines (#23268) (#23293)
* Use async await to fix empty quote reply at first time (#23168) (#23256)
* Fix switched citation format (#23250) (#23253)
* Allow `<video>` in MarkDown (#22892) (#23236)
* Order pull request conflict checking by recently updated, for each push (#23220) (#23225)
* Fix Fomantic UI's `touchstart` fastclick, always use `click` for click events (#23065) (#23195)
* Add word-break to sidebar-item-link (#23146) (#23180)
* Add InsecureSkipVerify to Minio Client for Storage (#23166) (#23177)
* Fix height for sticky head on large screen on PR page (#23111) (#23123)
* Change style to improve whitespaces trimming inside inline markdown code (#23093) (#23120)
* Avoid warning for system setting when start up (#23054) (#23116)
* Add accessibility to the menu on the navbar (#23059) (#23095)
* Improve accessibility for issue comments (#22612) (#23083)
* Remove delete button for review comment (#23036)
* Remove dashes between organization member avatars on hover (#23034)
* Use `gt-relative` class instead of the ambiguous `gt-pr` class (#23008)
* handle deprecated settings (#22992)
* Add scopes to API to create token and display them (#22989)
* Improve PR Review Box UI (#22986)
* Improve issues.LoadProject (#22982)
* Add all units to the units permission list in org team members sidebar (#22971)
* Rename `GetUnits` to `LoadUnits` (#22970)
* Rename `repo.GetOwner` to `repo.LoadOwner` (#22967)
* Rename "People" to "Members" in organization page and use a better icon (#22960)
* Fix avatar misalignment (#22955)
* Sort issues and pulls by recently updated in user and organization home (#22925)
* Add `title` to PR file tree items (#22918)
* First step to refactor the `.hide` to `.gt-hidden` (#22916)
* Add tooltip to issue reference (#22913)
* Always show the `command line instructions` button even if there are conflicts (#22909)
* Fix dark-colored description text in arc-green theme (#22908)
* Remove Fomantic-UI's `.hidden` CSS class for menu elements (#22895)
* Move helpers to be prefixed with `gt-` (#22879)
* Move `IsReadmeFile*` from `modules/markup/` to `modules/util` (#22877)
* Highlight focused diff file (#22870)
* Add some headings to repo views (#22869)
* Fix milestone title font problem (#22863)
* Pull Requests: setting to allow edits by maintainers by default, tweak UI (#22862)
* Introduce customized HTML elements, fix incorrect AppUrl usages in templates (#22861)
* Add `/$count` endpoints for NuGet v2 (#22855)
* Remove Fomantic-UI's `.hidden` CSS class for checkbox elements (#22851)
* Fix notification and stopwatch empty states (#22845)
* Always go full width in PR view (#22844)
* Improve AppUrl/ROOT_URL checking (#22836)
* Fix style of actions rerun button (#22835)
* Fix more HTMLURL in templates (#22831)
* Fix inconsistent Filter Project name in issue list (#22827)
* include build info in Prometheus metrics (#22819)
* Make clone URL use current page's host (#22808)
* Refactor legacy strange git operations (#22756)
* Improve error report when user passes a private key (#22726)
* set user dashboard org visibility to basic (#22706)
* Fix diff UI for unexpandable items (#22700)
* Remove 'primary' class from tab counter labels (#22687)
* Add more events details supports for actions (#22680)
* Refactor git command package to improve security and maintainability (#22678)
* Use relative url in actions view (#22675)
* set user visibility class to basic (#22674)
* Add repository setting to enable/disable releases unit (#22671)
* Remove label color from global issue filters (#22660)
* Fix poor alignment of organization description on organization home page (#22656)
* Small refactor for loading PRs (#22652)
* Allow setting access token scope by CLI (#22648)
* Improve accessibility of navigation bar and footer (#22635)
* Fixes accessibility behavior of Watching, Staring and Fork buttons (#22634)
* Fixes accessibility of empty repository commit status (#22632)
* Pull request yaml template support for including commit body in a field (#22629)
* Show migration validation error (#22619)
* set org visibility class to basic in header (#22605)
* Fix cache-control header clearing comment text when editing issue (#22604)
* Add ARIA support for Fomantic UI checkboxes (#22599)
* Add templates to customize text when creating and migrating repositories (#22597)
* Allow setting `redirect_to` cookie on OAuth login (#22594)
* Improve checkbox accessibility a bit by adding the title attribute (#22593)
* Allow issue templates to not render title (#22589)
* Webhooks: for issue close/reopen action, add commit ID that caused it (#22583)
* Fix missing title and filter in issue sidebar project menu (#22557)
* Issues: support setting issue template field values with query (#22545)
* Issues: add Project filter to issues list and search (#22544)
* Pull Requests: add color to approved/reject icon in pull requests list (#22543)
* Mute all links in issue timeline (#22533)
* Dropzone: Add "Copy link" button for new uploads (#22517)
* Support importing comment types (#22510)
* Load asciicast css async (#22502)
* Move delete user to service (#22478)
* Change use of Walk to WalkDir to improve disk performance (#22462)
* Add reply hint to mail text (#22459)
* fix wrong theme class when logged out if default theme is changed (#22408)
* Refactor the setting to make unit test easier (#22405)
* Improve utils of slices (#22379)
* Use context parameter in models/git (#22367)
* Always reuse transaction (#22362)
* Fix unstable emoji sort (#22346)
* Add context cache as a request level cache (#22294)
* Reminder for no more logs to console (#22282)
* Support estimated count with multiple schemas (#22276)
* Move `convert` package to services (#22264)
* Use dynamic package type list (#22263)
* Hide file borders on sticky diff box (#22217)
* Improve notification and stopwatch styles (#22169)
* Fixed Project view .board-column height for tall screens. (#22108)
* Use multi reader instead to concat strings (#22099)
* Use git command instead of exec.Cmd in blame (#22098)
* Fix autofilled text visibility in dark mode (#22088)
* Rename almost all Ctx functions (#22071)
* Rename actions to operations on UI (#22067)
* refactor bind functions based on generics (#22055)
* Support disabling database auto migration (#22053)
* remove duplicated read file code (#22042)
* Use link in UI which returned a relative url but not html_url which contains an absolute url (#21986)
* Skip initing disabled storages (#21985)
* Add doctor command for full GC of LFS (#21978)
* Util type to parse ref name (#21969)
* Replace fmt.Sprintf with hex.EncodeToString (#21960)
* Use random bytes to generate access token (#21959)
* Add index for access_token (#21908)
* Move all remaining colors into CSS variables (#21903)
* Webhook list enhancements (#21893)
* Embed Matrix icon as SVG (#21890)
* Remove useless "Cancel" buttons (#21872)
* fix(web): keep the pages of the navigation in the center (#21867)
* fix(web): reduce page jitter on browsers that support overlay scrollbar (#21850)
* Improvements for Content Copy (#21842)
* Tweak katex options (#21828)
* Show syntax lexer name in file view/blame (#21814)
* Remove `href="javascript:;"` in "save topics (Done)" button (#21813)
* Render number of commits in repo page in a user friendly way (#21786)
* Adjust clone timeout error to suggest increasing timeout (#21769)
* Update message of reach_limit_of_creation (#21757)
* Allow detect whether it's in a database transaction for a context.Context (#21756)
* Add configuration for CORS allowed headers (#21747)
* Move svg html render to modules/svg (#21716)
* Release and Tag List tweaks (#21712)
* Remove template previewer (#21701)
* Clean up formatting on install page (#21668)
* Configure update checker on installation page (#21655)
* Merge db.Iterate and IterateObjects (#21641)
* Add option to enable CAPTCHA validation for login (#21638)
* Allow disable RSS/Atom feed (#21622)
* Use CSS color-scheme instead of invert (#21616)
* Localize time units on activity heatmap (#21570)
* Fix UI column width, button overflow Fomantic's grid (#21559)
* feat: notify doers of a merge when automerging (#21553)
* Split migrations folder (#21549)
* feat: add button to quickly clear merge message (#21548)
* Add `context.Context` to more methods (#21546)
* Add index for hook_task table (#21545)
* Allow disable code tab (#20805)
* BUGFIXES
* Fix template error when reference Project (#23584)
* Fix dropdown icon misalignment when using fomantic icon (#23558) (#23577)
* Fix diff detail buttons wrapping, use tippy for review box (#23271) (#23546)
* Handle missing `README` in create repos API (#23387) (#23510)
* Disable sending email after push a commit to a closed PR (#23462) (#23492)
* Fix aria.js bugs: incorrect role element problem, mobile focus problem, tippy problem (#23450) (#23486)
* Fix due date being wrong on issue list (#23475) (#23477)
* Remove wrongly added column on migration test fixtures (#23456) (#23470)
* Make branches list page operations remember current page (#23420) (#23460)
* Fix missing commit status in PR which from forked repo (#23351) (#23453)
* Show edit/close/delete button on organization wide repositories (#23388) (#23429)
* Preserve file size when creating attachments (#23406) (#23426)
* Fix broken Chroma CSS styles (#23174) (#23402)
* Fix incorrect NotFound conditions in org/projects.go (#23384) (#23395)
* Set `X-Gitea-Debug` header once (#23361) (#23381)
* Pass context to avatar for projects view (#23359) (#23378)
* Fix panic when getting notes by ref (#23372) (#23377)
* Do not recognize text files as audio (#23355) (#23368)
* Fix adding of empty class name (#23352) (#23360)
* Fix various ImageDiff/SVG bugs (#23312) (#23358)
* Fix incorrect display for comment context menu (#23343) (#23344)
* Remove unnecessary space on link (#23334) (#23340)
* Fix incorrect redirect link of delete org project (#23327) (#23339)
* Fix cannot reopen after pushing commits to a closed PR (#23189) (#23324)
* Fix broken code editor diff preview (#23307) (#23320)
* Support sanitising the URL by removing extra slashes in the URL (#21333) (#23300)
* Avoid panic caused by broken payload when creating commit status (#23216) (#23294)
* Fill head commit to in payload when notifying push commits for mirroring (#23215) (#23292)
* Fix various bugs for "install" page (#23194) (#23286)
* Fix GetFilesChangedBetween if the file name may be escaped (#23272) (#23279)
* Revert relative links to absolute links in mail templates (#23267) (#23269)
* Fix commit retrieval by tag (#21804) (#23266)
* Use correct README link to render the README (#23152) (#23264)
* Close the temp file when dumping database to make the temp file can be deleted on Windows (#23249) (#23251)
* Use the correct selector to hide the checkmark of selected labels on clear (#23224) (#23228)
* Fix incorrect checkbox behaviors in the dashboard repolist's filter (#23147) (#23205)
* Properly flush unique queues on startup (#23154) (#23201)
* Pass `--global` when calling `git config --get`, for consistency with `git config --set` (#23157) (#23199)
* Make `gitea serv` respect git binary home (#23138) (#23197)
* Change button text for commenting and closing an issue at the same time (#23135) (#23182)
* Fix DBConsistency checks on MSSQL (#23132) (#23134)
* Show empty repos in Admin Repository Management page (#23114) (#23130)
* Redirect to the commit page after applying patch (#23056) (#23127)
* Fix nil context in RenderMarkdownToHtml (#23092) (#23108)
* Make issue meta dropdown support Enter, confirm before reloading (#23014) (#23102)
* Fix SyncOnCommit always return false in API of push_mirrors (#23088) (#23100)
* Fix commit name in Apply Patch page (#23086) (#23099)
* Fix some more hidden problems (#23074) (#23075)
* Bump golang.org/x/net from 0.4.0 to 0.7.0 (#22980)
* Get rules by id when editing branch protection rule (#22932)
* Fix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)
* Increase Content field size of gpg_import_key to MEDIUMTEXT (#22897)
* Fix hidden commit status on multiple checks (#22889)
* Fix update by rebase being wrongly disabled by protected base branch (#22825)
* Make issue title edit buttons focusable and fix incorrect ajax requests (#22807)
* Fix rerun button of Actions (#22798)
* remove update language in ProfilePost (#22748)
* Do not overwrite empty DefaultBranch (#22708)
* Fix ref to trigger Actions (#22679)
* Fix time to NotifyPullRequestSynchronized (#22650)
* Show all projects, not just repo projects and open/closed projects (#22640)
* Project links should use parent link methods (#22587)
* Fix group filter for ldap source sync (#22506)
* Check quota limits for container uploads (#22450)
* Fix halfCommitter and WithTx (#22366)
* Attempt to fix TestExportUserGPGKeys (#22159)
* Fix heatmap first color being unused (#22157)
* Fix scroll over mermaid frame (#21925)
* Move migration test fixtures to the correct directories (#21901)
* fix(web): add `alt` for logo in home page (#21887)
* Fix webhook attachment text is not set in review comment (#21763)
* Alter package_version.metadata_json to LONGTEXT (#21667)
* Ensure that Webhook tasks are not double delivered (#21558)
* TESTING
* Make CI use a dummy password hasher for all tests (#22983)
* Disable test for incoming email (#22686)
* Move fuzz tests into tests/fuzz (#22376)
* Test views of LFS files (#22196)
* Specify ID in `TestAPITeam` (#22192)
* verify nodeinfo response by schema (#22137)
* Skip GitHub migration tests if the API token is undefined (#21824)
* Add a simple test for external renderer (#20033)
* TRANSLATION
* Use "Title Case" for text "Reference in new issue" (#22936)
* BUILD
* Wrap unless-check in docker manifests (#23079) (#23081)
* Adjust manifest to prevent tagging latest on rcs (#22811)
* update to build with go1.20 (#22732)
* Add Bash and Zsh completion scripts (#22646)
* Add Contributed backport command (#22643)
* Remove deprecated packages & staticcheck fixes (#22012)
* Update to Alpine 3.17 (#21904)
* Fix webpack license warning (#21815)
* DOCS
* Update documentation for the new YAML label file format (#23020) (#23341)
* Update hacking-on-gitea-zh_cn documentation (#23315) (#23323)
* Add basic documentation for labels, including scoped labels (#23304) (#23309)
* Re-add accidentally removed `hacking-on-gitea.zh-cn.md` (#23297) (#23305)
* Fix secrets overview page missing from docs sidebar (#23143) (#23145)
* Add some guidelines for refactoring (#22880)
* Explain that the no-access team unit does not affect public repositories (#22661)
* Fix incorrect Redis URL snippets in the example app.ini (#22573)
* docs: add swagger.json file location to FAQ (#22489)
* Update index.de-de.md (#22363)
* Update Gmail mailer configuration (#22291)
* Add missed reverse proxy authentication documentation (#22250)
* Add plural definitions for German translations (#21802)
* Attempt clarify AppWorkPath etc. (#21656)
* Add some documentation to packages (#21648)
* MISC
* Use `<nav>` instead of `<div>` in the global navbar (#23125) (#23533)
* Do not create commit graph for temporary repos (#23219) (#23229)
* Update button is shown when a Pull Request is marked WIP - Issue #21740 (#22683)
* Add main landmark to templates and adjust titles (#22670)
* Fix error on account activation with wrong passwd (#22609)
* Update JS dependencies (#22538)
* Display unreferenced packages total size in package admin panel (#22498)
* Mobile fix for Project view: Add delay to Sortable.js on mobile, to ensure scrolling is possible. (#22152)
* Update chroma to v2.4.0 (#22000)
* Hide collapse icon in diff with no lines (#21094)
## [1.18.5](https://github.com/go-gitea/gitea/releases/tag/v1.18.5) - 2023-02-21 ## [1.18.5](https://github.com/go-gitea/gitea/releases/tag/v1.18.5) - 2023-02-21
* ENHANCEMENTS * ENHANCEMENTS

View File

@@ -105,7 +105,7 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m
FOMANTIC_WORK_DIR := web_src/fomantic FOMANTIC_WORK_DIR := web_src/fomantic
WEBPACK_SOURCES := $(shell find web_src/js web_src/less -type f) WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
WEBPACK_CONFIGS := webpack.config.js WEBPACK_CONFIGS := webpack.config.js
WEBPACK_DEST := public/js/index.js public/css/index.css WEBPACK_DEST := public/js/index.js public/css/index.css
WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack public/serviceworker.js
@@ -131,7 +131,7 @@ TEST_TAGS ?= sqlite sqlite_unlock_notify
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR) TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
GO_DIRS := cmd tests models modules routers build services tools GO_DIRS := cmd tests models modules routers build services tools
WEB_DIRS := web_src/js web_src/less WEB_DIRS := web_src/js web_src/css
GO_SOURCES := $(wildcard *.go) GO_SOURCES := $(wildcard *.go)
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go) GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
@@ -341,7 +341,7 @@ lint: lint-frontend lint-backend
.PHONY: lint-frontend .PHONY: lint-frontend
lint-frontend: node_modules lint-frontend: node_modules
npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e npx eslint --color --max-warnings=0 --ext js,vue web_src/js build *.config.js docs/assets/js tests/e2e
npx stylelint --color --max-warnings=0 web_src/less npx stylelint --color --max-warnings=0 web_src/css
npx spectral lint -q -F hint $(SWAGGER_SPEC) npx spectral lint -q -F hint $(SWAGGER_SPEC)
npx markdownlint docs *.md npx markdownlint docs *.md
@@ -859,6 +859,8 @@ fomantic:
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/ cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js
$(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js $(SED_INPLACE) -e 's/\r//g' $(FOMANTIC_WORK_DIR)/build/semantic.css $(FOMANTIC_WORK_DIR)/build/semantic.js
rm -f $(FOMANTIC_WORK_DIR)/build/*.min.* rm -f $(FOMANTIC_WORK_DIR)/build/*.min.*

File diff suppressed because one or more lines are too long

View File

@@ -7,6 +7,7 @@ package cmd
import ( import (
"errors" "errors"
"fmt" "fmt"
"net/url"
"os" "os"
"strings" "strings"
"text/tabwriter" "text/tabwriter"
@@ -469,11 +470,19 @@ func runAddOauth(c *cli.Context) error {
return err return err
} }
config := parseOAuth2Config(c)
if config.Provider == "openidConnect" {
discoveryURL, err := url.Parse(config.OpenIDConnectAutoDiscoveryURL)
if err != nil || (discoveryURL.Scheme != "http" && discoveryURL.Scheme != "https") {
return fmt.Errorf("invalid Auto Discovery URL: %s (this must be a valid URL starting with http:// or https://)", config.OpenIDConnectAutoDiscoveryURL)
}
}
return auth_model.CreateSource(&auth_model.Source{ return auth_model.CreateSource(&auth_model.Source{
Type: auth_model.OAuth2, Type: auth_model.OAuth2,
Name: c.String("name"), Name: c.String("name"),
IsActive: true, IsActive: true,
Cfg: parseOAuth2Config(c), Cfg: config,
}) })
} }

View File

@@ -35,7 +35,7 @@ func runConvert(ctx *cli.Context) error {
log.Info("Log path: %s", setting.Log.RootPath) log.Info("Log path: %s", setting.Log.RootPath)
log.Info("Configuration file: %s", setting.CustomConf) log.Info("Configuration file: %s", setting.CustomConf)
if !setting.Database.UseMySQL { if !setting.Database.Type.IsMySQL() {
fmt.Println("This command can only be used with a MySQL database") fmt.Println("This command can only be used with a MySQL database")
return nil return nil
} }

View File

@@ -272,13 +272,14 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to create tmp file: %v", err) fatal("Failed to create tmp file: %v", err)
} }
defer func() { defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil { if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err) log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
} }
}() }()
targetDBType := ctx.String("database") targetDBType := ctx.String("database")
if len(targetDBType) > 0 && targetDBType != setting.Database.Type { if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType) log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
} else { } else {
log.Info("Dumping database...") log.Info("Dumping database...")

View File

@@ -11,6 +11,7 @@ import (
"net/url" "net/url"
"os" "os"
"os/exec" "os/exec"
"path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
@@ -290,17 +291,21 @@ func runServ(c *cli.Context) error {
return nil return nil
} }
// Special handle for Windows.
if setting.IsWindows {
verb = strings.Replace(verb, "-", " ", 1)
}
var gitcmd *exec.Cmd var gitcmd *exec.Cmd
verbs := strings.Split(verb, " ") gitBinPath := filepath.Dir(git.GitExecutable) // e.g. /usr/bin
if len(verbs) == 2 { gitBinVerb := filepath.Join(gitBinPath, verb) // e.g. /usr/bin/git-upload-pack
gitcmd = exec.CommandContext(ctx, verbs[0], verbs[1], repoPath) if _, err := os.Stat(gitBinVerb); err != nil {
} else { // if the command "git-upload-pack" doesn't exist, try to split "git-upload-pack" to use the sub-command with git
gitcmd = exec.CommandContext(ctx, verb, repoPath) // ps: Windows only has "git.exe" in the bin path, so Windows always uses this way
verbFields := strings.SplitN(verb, "-", 2)
if len(verbFields) == 2 {
// use git binary with the sub-command part: "C:\...\bin\git.exe", "upload-pack", ...
gitcmd = exec.CommandContext(ctx, git.GitExecutable, verbFields[1], repoPath)
}
}
if gitcmd == nil {
// by default, use the verb (it has been checked above by allowedCommands)
gitcmd = exec.CommandContext(ctx, gitBinVerb, repoPath)
} }
process.SetSysProcAttribute(gitcmd) process.SetSysProcAttribute(gitcmd)

View File

@@ -1832,7 +1832,7 @@ ROUTER = console
;ENABLED = true ;ENABLED = true
;; ;;
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. ;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip ;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
;; ;;
;; Max size of each file. Defaults to 4MB ;; Max size of each file. Defaults to 4MB
;MAX_SIZE = 4 ;MAX_SIZE = 4
@@ -1871,6 +1871,9 @@ ROUTER = console
;; ;;
;; Minio enabled ssl only available when STORAGE_TYPE is `minio` ;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
;MINIO_USE_SSL = false ;MINIO_USE_SSL = false
;;
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
;MINIO_INSECURE_SKIP_VERIFY = false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2253,6 +2256,17 @@ ROUTER = console
;PULL = 300 ;PULL = 300
;GC = 60 ;GC = 60
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Git Reflog timeout in days
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[git.reflog]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;ENABLED = true
;EXPIRATION = 90
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[mirror] ;[mirror]
@@ -2552,6 +2566,9 @@ ROUTER = console
;; ;;
;; Minio enabled ssl only available when STORAGE_TYPE is `minio` ;; Minio enabled ssl only available when STORAGE_TYPE is `minio`
;MINIO_USE_SSL = false ;MINIO_USE_SSL = false
;;
;; Minio skip SSL verification available when STORAGE_TYPE is `minio`
;MINIO_INSECURE_SKIP_VERIFY = false
;[proxy] ;[proxy]
;; Enable the proxy, all requests to external via HTTP will be affected ;; Enable the proxy, all requests to external via HTTP will be affected

View File

@@ -1,6 +1,6 @@
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}}-rootless image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}}-rootless
{{#if build.tags}} {{#if build.tags}}
{{#unless contains "-rc" build.tag}} {{#unless (contains "-rc" build.tag)}}
tags: tags:
{{#each build.tags}} {{#each build.tags}}
- {{this}}-rootless - {{this}}-rootless

View File

@@ -1,6 +1,6 @@
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}} image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}{{#if (hasPrefix "refs/heads/release/v" build.ref)}}{{trimPrefix "refs/heads/release/v" build.ref}}-{{/if}}dev{{/if}}
{{#if build.tags}} {{#if build.tags}}
{{#unless contains "-rc" build.tag }} {{#unless (contains "-rc" build.tag)}}
tags: tags:
{{#each build.tags}} {{#each build.tags}}
- {{this}} - {{this}}

View File

@@ -1,6 +1,6 @@
THEME := themes/gitea THEME := themes/gitea
PUBLIC := public PUBLIC := public
ARCHIVE := https://dl.gitea.io/theme/master.tar.gz ARCHIVE := https://dl.gitea.com/theme/main.tar.gz
HUGO_PACKAGE := github.com/gohugoio/hugo@v0.82.0 HUGO_PACKAGE := github.com/gohugoio/hugo@v0.82.0

View File

@@ -841,7 +841,7 @@ Default templates for project boards:
## Issue and pull request attachments (`attachment`) ## Issue and pull request attachments (`attachment`)
- `ENABLED`: **true**: Whether issue and pull request attachments are enabled. - `ENABLED`: **true**: Whether issue and pull request attachments are enabled.
- `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types. - `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
- `MAX_SIZE`: **4**: Maximum size (MB). - `MAX_SIZE`: **4**: Maximum size (MB).
- `MAX_FILES`: **5**: Maximum number of attachments that can be uploaded at once. - `MAX_FILES`: **5**: Maximum number of attachments that can be uploaded at once.
- `STORAGE_TYPE`: **local**: Storage type for attachments, `local` for local disk or `minio` for s3 compatible object storage service, default is `local` or other name defined with `[storage.xxx]` - `STORAGE_TYPE`: **local**: Storage type for attachments, `local` for local disk or `minio` for s3 compatible object storage service, default is `local` or other name defined with `[storage.xxx]`
@@ -854,6 +854,7 @@ Default templates for project boards:
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when STORAGE_TYPE is `minio` - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when STORAGE_TYPE is `minio`
- `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket only available when STORAGE_TYPE is `minio` - `MINIO_BASE_PATH`: **attachments/**: Minio base path on the bucket only available when STORAGE_TYPE is `minio`
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio`
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
## Log (`log`) ## Log (`log`)
@@ -1086,6 +1087,11 @@ Default templates for project boards:
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false. - `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
- `DISABLE_PARTIAL_CLONE`: **false** Disable the usage of using partial clones for git. - `DISABLE_PARTIAL_CLONE`: **false** Disable the usage of using partial clones for git.
## Git - Reflog settings (`git.reflog`)
- `ENABLED`: **true** Set to true to enable Git to write changes to reflogs in each repo.
- `EXPIRATION`: **90** Reflog entry lifetime, in days. Entries are removed opportunistically by Git.
## Git - Timeout settings (`git.timeout`) ## Git - Timeout settings (`git.timeout`)
- `DEFAULT`: **360**: Git operations default timeout seconds. - `DEFAULT`: **360**: Git operations default timeout seconds.
@@ -1268,6 +1274,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`.
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
- `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
## Storage (`storage`) ## Storage (`storage`)
@@ -1280,6 +1287,7 @@ Default storage configuration for attachments, lfs, avatars and etc.
- `MINIO_BUCKET`: **gitea**: Minio bucket to store the data only available when `STORAGE_TYPE` is `minio` - `MINIO_BUCKET`: **gitea**: Minio bucket to store the data only available when `STORAGE_TYPE` is `minio`
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
And you can also define a customize storage like below: And you can also define a customize storage like below:
@@ -1298,6 +1306,8 @@ MINIO_BUCKET = gitea
MINIO_LOCATION = us-east-1 MINIO_LOCATION = us-east-1
; Minio enabled ssl only available when STORAGE_TYPE is `minio` ; Minio enabled ssl only available when STORAGE_TYPE is `minio`
MINIO_USE_SSL = false MINIO_USE_SSL = false
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
MINIO_INSECURE_SKIP_VERIFY = false
``` ```
And used by `[attachment]`, `[lfs]` and etc. as `STORAGE_TYPE`. And used by `[attachment]`, `[lfs]` and etc. as `STORAGE_TYPE`.
@@ -1318,6 +1328,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`.
- `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio`
- `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio`
- `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio`
- `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio`
## Proxy (`proxy`) ## Proxy (`proxy`)

View File

@@ -431,6 +431,8 @@ MINIO_BUCKET = gitea
MINIO_LOCATION = us-east-1 MINIO_LOCATION = us-east-1
; Minio enabled ssl only available when STORAGE_TYPE is `minio` ; Minio enabled ssl only available when STORAGE_TYPE is `minio`
MINIO_USE_SSL = false MINIO_USE_SSL = false
; Minio skip SSL verification available when STORAGE_TYPE is `minio`
MINIO_INSECURE_SKIP_VERIFY = false
``` ```
然后你在 `[attachment]`, `[lfs]` 等中可以把这个名字用作 `STORAGE_TYPE` 的值。 然后你在 `[attachment]`, `[lfs]` 等中可以把这个名字用作 `STORAGE_TYPE` 的值。

View File

@@ -282,9 +282,22 @@ To add custom .gitignore, add a file with existing [.gitignore rules](https://gi
### Labels ### Labels
To add a custom label set, add a file that follows the [label format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) to `$GITEA_CUSTOM/options/label` Starting with Gitea 1.19, you can add a file that follows the [YAML label format](https://github.com/go-gitea/gitea/blob/main/options/label/Advanced.yaml) to `$GITEA_CUSTOM/options/label`:
```yaml
labels:
- name: "foo/bar" # name of the label that will appear in the dropdown
exclusive: true # whether to use the exclusive namespace for scoped labels. scoped delimiter is /
color: aabbcc # hex colour coding
description: Some label # long description of label intent
```
The [legacy file format](https://github.com/go-gitea/gitea/blob/main/options/label/Default) can still be used following the format below, however we strongly recommend using the newer YAML format instead.
`#hex-color label name ; label description` `#hex-color label name ; label description`
For more information, see the [labels documentation]({{< relref "doc/usage/labels.en-us.md" >}}).
### Licenses ### Licenses
To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license` To add a custom license, add a file with the license text to `$GITEA_CUSTOM/options/license`
@@ -341,7 +354,7 @@ To make a custom theme available to all users:
Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes). Community themes are listed in [gitea/awesome-gitea#themes](https://gitea.com/gitea/awesome-gitea#themes).
The `arc-green` theme source can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/less/themes/theme-arc-green.less). The `arc-green` theme source can be found [here](https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-arc-green.css).
If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`. If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`.
This allows Gitea to adjust the Monaco code editor's theme accordingly. This allows Gitea to adjust the Monaco code editor's theme accordingly.

View File

@@ -21,13 +21,13 @@ menu:
## Background ## Background
Gitea uses [Less CSS](https://lesscss.org), [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend. Gitea uses [Fomantic-UI](https://fomantic-ui.com/introduction/getting-started.html) (based on [jQuery](https://api.jquery.com)) and [Vue3](https://vuejs.org/) for its frontend.
The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template). The HTML pages are rendered by [Go HTML Template](https://pkg.go.dev/html/template).
The source files can be found in the following directories: The source files can be found in the following directories:
* **Less styles:** `web_src/less/` * **CSS styles:** `web_src/css/`
* **JavaScript files:** `web_src/js/` * **JavaScript files:** `web_src/js/`
* **Vue components:** `web_src/js/components/` * **Vue components:** `web_src/js/components/`
* **Go HTML templates:** `templates/` * **Go HTML templates:** `templates/`

View File

@@ -0,0 +1,349 @@
---
date: "2016-12-01T16:00:00+02:00"
title: "玩转 Gitea"
slug: "hacking-on-gitea"
weight: 10
toc: false
draft: false
menu:
sidebar:
parent: "developers"
name: "玩转 Gitea"
weight: 10
identifier: "hacking-on-gitea"
---
# Hacking on Gitea
**目录**
{{< toc >}}
## 快速入门
要获得快速工作的开发环境,您可以使用 Gitpod。
[![在 Gitpod 中打开](/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea)
## 安装 Golang
您需要 [安装 go]( https://golang.org/doc/install ) 并设置您的 go 环境。
接下来,[使用 npm 安装 Node.js](https://nodejs.org/en/download/) ,这是构建
JavaScript 和 CSS 文件的必要工具。最低支持的 Node.js 版本是 {{< min-node-version >}}
并且推荐使用最新的 LTS 版本。
**注意** :当执行需要外部工具的 make 任务时,比如
`make watch-backend`Gitea 会自动下载并构建这些必要的组件。为了能够使用这些,你必须
`"$GOPATH"/bin` 目录加入到可执行路径上。如果你不把go bin目录添加到可执行路径你必须手动
指定可执行程序路径。
**注意2** Go版本 {{< min-go-version >}} 或更高版本是必须的。Gitea 使用 `gofmt`
格式化源代码。然而,`gofmt` 的结果可能因 `go` 的版本而有差异。因此推荐安装我们持续集成使用
的 Go版本。截至上次更新Go 版本应该是 {{< go-version >}}。
## 安装 Make
Gitea 大量使用 `Make` 来自动化任务和改进开发。本指南涵盖了如何安装 Make。
### 在 Linux 上
使用包管理器安装。
在 Ubuntu/Debian 上:
```bash
sudo apt-get install make
```
在 Fedora/RHEL/CentOS 上:
```bash
sudo yum install make
```
### 在 Windows 上
Make 的这三个发行版都可以在 Windows 上运行:
- [单个二进制构建]( http://www.equation.com/servlet/equation.cmd?fa=make )。复制到某处并添加到 `PATH`
- [32 位版本](http://www.equation.com/ftpdir/make/32/make.exe)
- [64 位版本](http://www.equation.com/ftpdir/make/64/make.exe)
- [MinGW-w64](https://www.mingw-w64.org) / [MSYS2](https://www.msys2.org/)。
- MSYS2 是一个工具和库的集合,为您提供一个易于使用的环境来构建、安装和运行本机 Windows 软件,它包括 MinGW-w64。
- 在 MingGW-w64 中,二进制文件称为 `mingw32-make.exe` 而不是 `make.exe`。将 `bin` 文件夹添加到 `PATH`
- 在 MSYS2 中,您可以直接使用 `make`。请参阅 [MSYS2 移植](https://www.msys2.org/wiki/Porting/)。
- 要使用 CGO_ENABLED例如SQLite3编译 Gitea您可能需要使用 [tdm-gcc](https://jmeubank.github.io/tdm-gcc/) 而不是 MSYS2 gcc因为 MSYS2 gcc 标头缺少一些 Windows -只有 CRT 函数像 _beginthread 一样。
- [Chocolatey包管理器]( https://chocolatey.org/packages/make )。运行`choco install make`
**注意** :如果您尝试在 Windows 命令提示符下使用 make 进行构建您可能会遇到问题。建议使用上述提示Git bash 或 MinGW但是如果您只有命令提示符或可能是 PowerShell则可以使用 [set](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1) 命令,例如 `set TAGS=bindata`
## 下载并克隆 Gitea 源代码
获取源代码的推荐方法是使用 `git clone`
```bash
git clone https://github.com/go-gitea/gitea
```
自从go modules出现后不再需要构建 go 项目从 `$GOPATH` 中获取,因此不再推荐使用 `go get` 方法。)
## 派生 Gitea
如上所述下载主要的 Gitea 源代码。然后,派生 [Gitea 仓库](https://github.com/go-gitea/gitea)
并为您的本地仓库切换 git 远程源,或添加另一个远程源:
```bash
# 将原来的 Gitea origin 重命名为 upstream
git remote rename origin upstream
git remote add origin "git@github.com:$GITHUB_USERNAME/gitea.git"
git fetch --all --prune
```
或者:
```bash
# 为我们的 fork 添加新的远程
git remote add "$FORK_NAME" "git@github.com:$GITHUB_USERNAME/gitea.git"
git fetch --all --prune
```
为了能够创建合并请求,应将分叉存储库添加为 Gitea 本地仓库的远程,否则无法推送更改。
## 构建 Gitea基本
看看我们的
<a href='{{ < relref "doc/installation/from-source.en-us.md" > }}'>说明</a>
关于如何 <a href='{{ < relref "doc/installation/from-source.en-us.md" > }}'>从源代码构建</a>
从源代码构建的最简单推荐方法是:
```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build
```
`build` 目标将同时执行 `frontend``backend` 子目标。如果存在 `bindata` 标签,资源文件将被编译成二进制文件。建议在进行前端开发时省略 `bindata` 标签,以便实时反映更改。
有关所有可用的 `make` 目标,请参阅 `make help`。另请参阅 [`.drone.yml`](https://github.com/go-gitea/gitea/blob/main/.drone.yml) 以了解我们的持续集成是如何工作的。
## 持续构建
要在源文件更改时运行并持续构建:
```bash
# 对于前端和后端
make watch
# 或者只看前端文件html/js/css
make watch-frontend
# 或者:只看后端文件 (go)
make watch-backend
```
在 macOS 上,监视所有后端源文件可能会达到默认的打开文件限制,这可以通过当前 shell 的 `ulimit -n 12288` 或所有未来 shell 的 shell 启动文件来增加。
### 格式化、代码分析和拼写检查
我们的持续集成将拒绝未通过代码检查(包括格式检查、代码分析和拼写检查)的 PR。
你应该格式化你的代码:
```bash
make fmt
```
并检查源代码:
```bash
# lint 前端和后端代码
make lint
# 仅 lint 后端代码
make lint-backend
```
**注意** `gofmt` 的结果取决于 `go` 的版本。您应该运行与持续集成相同的 go 版本。
### 处理 JS 和 CSS
前端开发应遵循 [Guidelines for Frontend Development]({{ < 相关参考 "doc/developers/guidelines-frontend.en-us.md" > }})
要使用前端资源构建请使用上面提到的“watch-frontend”目标或只构建一次
```bash
make build && ./gitea
```
在提交之前,确保 linters 通过:
```bash
make lint-frontend
```
### 配置本地 ElasticSearch 实例
使用 docker 启动本地 ElasticSearch 实例:
```sh
mkdir -p $(pwd) /data/elasticsearch
sudo chown -R 1000:1000 $(pwd) /data/elasticsearch
docker run --rm --memory= "4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data /elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3
```
配置`app.ini`
```ini
[indexer]
ISSUE_INDEXER_TYPE = elasticsearch
ISSUE_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
REPO_INDEXER_ENABLED = true
REPO_INDEXER_TYPE = elasticsearch
REPO_INDEXER_CONN_STR = http://elastic:changeme@localhost:9200
```
### 构建和添加 SVGs
SVG 图标是使用 `make svg` 目标构建的,该目标将 `build/generate-svg.js` 中定义的图标源编译到输出目录 `public/img/svg` 中。可以在 `web_src/svg` 目录中添加自定义图标。
### 构建 Logo
Gitea Logo的 PNG 和 SVG 版本是使用 `TAGS="gitea" make generate-images` 目标从单个 SVG 源文件 assets/logo.svg 构建的。要运行它Node.js 和 npm 必须可用。
通过更新 `assets/logo.svg` 并运行 `make generate-images`,同样的过程也可用于从 SVG 源文件生成自定义 Logo PNG。忽略 gitea 编译选项将仅更新用户指定的 LOGO 文件。
### 更新 API
创建新的 API 路由或修改现有的 API 路由时,您**必须**
更新和/或创建 [Swagger](https://swagger.io/docs/specification/2-0/what-is-swagger/)
这些使用 [go-swagger](https://goswagger.io/) 评论的文档。
[规范]( https://goswagger.io/use/spec.html#annotation-syntax )中描述了这些注释的结构。
如果您想了解更多有关 Swagger 结构的信息,可以查看
[Swagger 2.0 文档](https://swagger.io/docs/specification/2-0/basic-structure/)
或与添加新 API 端点的先前 PR 进行比较,例如 [PR #5483](https://github.com/go-gitea/gitea/pull/5843/files#diff-2e0a7b644cf31e1c8ef7d76b444fe3aaR20)
您应该注意不要破坏下游用户依赖的 API。在稳定的 API 上,一般来说添加是可以接受的,但删除
或对 API 进行根本性更改将会被拒绝。
创建或更改 API 端点后,请用以下命令重新生成 Swagger 文档:
```bash
make generate-swagger
```
您应该验证生成的 Swagger 文件并使用以下命令对其进行拼写检查:
```bash
make swagger-validate misspell-check
```
您应该提交更改后的 swagger JSON 文件。持续集成服务器将使用以下方法检查是否已完成:
```bash
make swagger-check
```
**注意** :请注意,您应该使用 Swagger 2.0 文档,而不是 OpenAPI 3 文档。
### 创建新的配置选项
创建新的配置选项时,将它们添加到 `modules/setting` 的对应文件。您应该将信息添加到 `custom/conf/app.ini`
并到 <a href = '{{ < relref "doc/advanced/config-cheat-sheet.en-us.md" > }}'>配置备忘单</a>
`docs/content/doc/advanced/config-cheat-sheet.en-us.md` 中找到
### 更改Logo
更改 Gitea Logo SVG 时,您将需要运行并提交结果的:
```bash
make generate-images
```
这将创建必要的 Gitea 图标和其他图标。
### 数据库迁移
如果您对数据库中的任何数据库持久结构进行重大更改
`models/` 目录,您将需要进行新的迁移。可以找到这些
`models/migrations/` 中。您可以确保您的迁移适用于主要
数据库类型使用:
```bash
make test-sqlite-migration # 将 SQLite 切换为适当的数据库
```
## 测试
Gitea 运行两种类型的测试:单元测试和集成测试。
### 单元测试
`go test` 系统中的`*_test.go` 涵盖了单元测试。
您可以设置环境变量 `GITEA_UNIT_TESTS_LOG_SQL=1` 以在详细模式下运行测试时显示所有 SQL 语句(即设置`GOTESTFLAGS=-v` 时)。
```bash
TAGS="bindata sqlite sqlite_unlock_notify" make test # Runs the unit tests
```
### 集成测试
单元测试不会也不能完全单独测试 Gitea。因此我们编写了集成测试但是这些依赖于数据库。
```bash
TAGS="bindata sqlite sqlite_unlock_notify" make build test-sqlite
```
将在 SQLite 环境中运行集成测试。集成测试需要安装 `git lfs`。其他数据库测试可用,但
可能需要适应当地环境。
看看 [`tests/integration/README.md`](https://github.com/go-gitea/gitea/blob/main/tests/integration/README.md) 有关更多信息以及如何运行单个测试。
### 测试 PR
我们的持续集成将测试代码是否通过了单元测试,并且所有支持的数据库都将在 Docker 环境中通过集成测试。
还将测试从几个最新版本的 Gitea 迁移。
请在PR中附带提交适当的单元测试和集成测试。
## 网站文档
该网站的文档位于 `docs/` 中。如果你改变了文档内容,你可以使用以下测试方法进行持续集成:
```bash
# 来自 Gitea 中的 docs 目录
make trans-copy clean build
```
运行此任务依赖于 [Hugo](https://gohugo.io/)。请注意:这可能会生成一些未跟踪的 Git 对象,
需要被清理干净。
## Visual Studio Code
`contrib/ide/vscode` 中为 Visual Studio Code 提供了 `launch.json``tasks.json`。查看
[`contrib/ide/README.md`](https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md) 了解更多信息。
## Goland
单击 `/main.go` 中函数 `func main()` 上的 `Run Application` 箭头
可以快速启动一个可调试的 Gitea 实例。
`Run/Debug Configuration` 中的 `Output Directory` 必须设置为
gitea 项目目录(包含 `main.go``go.mod`
否则,启动实例的工作目录是 GoLand 的临时目录
并防止 Gitea 在开发环境中加载动态资源(例如:模板)。
要在 GoLand 中使用 SQLite 运行单元测试,请设置 `-tags sqlite,sqlite_unlock_notify`
`运行/调试配置``Go 工具参数` 中。
## 提交 PR
对更改感到满意后,将它们推送并打开拉取请求。它建议您允许 Gitea Managers 和 Owners 修改您的 PR
分支,因为我们需要在合并之前将其更新为 main 和/或可能是能够直接帮助解决问题。
任何 PR 都需要 Gitea 维护者的两次批准,并且需要通过持续集成。看看我们的
[CONTRIBUTING.md](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
文档。
如果您需要更多帮助,请访问 [Discord](https://discord.gg/gitea) #Develop 频道
并在那里聊天。
现在,您已准备好 Hacking Gitea。

View File

@@ -9,7 +9,7 @@ menu:
parent: "packages" parent: "packages"
name: "Overview" name: "Overview"
weight: 1 weight: 1
identifier: "overview" identifier: "packages-overview"
--- ---
# Package Registry # Package Registry

View File

@@ -9,7 +9,7 @@ menu:
parent: "secrets" parent: "secrets"
name: "Overview" name: "Overview"
weight: 1 weight: 1
identifier: "overview" identifier: "secrets-overview"
--- ---
# Secrets # Secrets

View File

@@ -0,0 +1,40 @@
---
date: "2023-03-04T19:00:00+00:00"
title: "Usage: Labels"
slug: "labels"
weight: 13
toc: false
draft: false
menu:
sidebar:
parent: "usage"
name: "Labels"
weight: 13
identifier: "labels"
---
# Labels
You can use labels to classify issues and pull requests and to improve your overview over them.
## Creating Labels
For repositories, labels can be created by going to `Issues` and clicking on `Labels`.
For organizations, you can define organization-wide labels that are shared with all organization repositories, including both already-existing repositories as well as newly created ones. Organization-wide labels can be created in the organization `Settings`.
Labels have a mandatory name, a mandatory color, an optional description, and must either be exclusive or not (see `Scoped Labels` below).
When you create a repository, you can ensure certain labels exist by using the `Issue Labels` option. This option lists a number of available label sets that are [configured globally on your instance](../customizing-gitea/#labels). Its contained labels will all be created as well while creating the repository.
## Scoped Labels
Scoped labels are used to ensure at most a single label with the same scope is assigned to an issue or pull request. For example, if labels `kind/bug` and `kind/enhancement` have the Exclusive option set, an issue can only be classified as a bug or an enhancement.
A scoped label must contain `/` in its name (not at either end of the name). The scope of a label is determined based on the **last** `/`, so for example the scope of label `scope/subscope/item` is `scope/subscope`.
## Filtering by Label
Issue and pull request lists can be filtered by label. Selecting multiple labels shows issues and pull requests that have all selected labels assigned.
By holding alt to click the label, issues and pull requests with the chosen label are excluded from the list.

13
go.mod
View File

@@ -41,7 +41,7 @@ require (
github.com/go-chi/cors v1.2.1 github.com/go-chi/cors v1.2.1
github.com/go-enry/go-enry/v2 v2.8.3 github.com/go-enry/go-enry/v2 v2.8.3
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e
github.com/go-git/go-billy/v5 v5.4.0 github.com/go-git/go-billy/v5 v5.4.1
github.com/go-git/go-git/v5 v5.5.2 github.com/go-git/go-git/v5 v5.5.2
github.com/go-ldap/ldap/v3 v3.4.4 github.com/go-ldap/ldap/v3 v3.4.4
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
@@ -77,7 +77,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.21 github.com/microcosm-cc/bluemonday v1.0.21
github.com/minio/minio-go/v7 v7.0.46 github.com/minio/minio-go/v7 v7.0.46
github.com/msteinert/pam v1.1.0 github.com/msteinert/pam v1.1.0
github.com/nektos/act v0.0.0 github.com/nektos/act v0.2.43
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/niklasfasching/go-org v1.6.5 github.com/niklasfasching/go-org v1.6.5
github.com/oliamb/cutter v0.2.2 github.com/oliamb/cutter v0.2.2
@@ -105,7 +105,7 @@ require (
golang.org/x/crypto v0.4.0 golang.org/x/crypto v0.4.0
golang.org/x/net v0.7.0 golang.org/x/net v0.7.0
golang.org/x/oauth2 v0.3.0 golang.org/x/oauth2 v0.3.0
golang.org/x/sys v0.5.0 golang.org/x/sys v0.6.0
golang.org/x/text v0.7.0 golang.org/x/text v0.7.0
golang.org/x/tools v0.1.12 golang.org/x/tools v0.1.12
google.golang.org/grpc v1.47.0 google.golang.org/grpc v1.47.0
@@ -172,7 +172,6 @@ require (
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
github.com/go-enry/go-oniguruma v1.2.1 // indirect github.com/go-enry/go-oniguruma v1.2.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect github.com/go-openapi/inflect v0.19.0 // indirect
@@ -239,7 +238,7 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect
github.com/rhysd/actionlint v1.6.22 // indirect github.com/rhysd/actionlint v1.6.23 // indirect
github.com/rivo/uniseg v0.4.3 // indirect github.com/rivo/uniseg v0.4.3 // indirect
github.com/robfig/cron v1.2.0 // indirect github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect
@@ -271,7 +270,7 @@ require (
go.uber.org/multierr v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.7.0 // indirect golang.org/x/mod v0.7.0 // indirect
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect golang.org/x/sync v0.1.0 // indirect
golang.org/x/time v0.3.0 // indirect golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
@@ -286,7 +285,7 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix
replace github.com/nektos/act => gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744 replace github.com/nektos/act => gitea.com/gitea/act v0.243.1
exclude github.com/gofrs/uuid v3.2.0+incompatible exclude github.com/gofrs/uuid v3.2.0+incompatible

25
go.sum
View File

@@ -70,8 +70,8 @@ codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsi
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg= git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs= git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744 h1:cqzKmGlX0wynSXO04NILpL25eBGwogDrKpkkbwmIpj4= gitea.com/gitea/act v0.243.1 h1:zIVlhGOLE4SHFPW++u3+5Y/jX5mub3QIhB13oNf6rtA=
gitea.com/gitea/act v0.234.2-0.20230131074955-e46ede1b1744/go.mod h1:2C/WbTalu1VPNgbVaZJaZDzlOtAKqkXJhdOClxkMy14= gitea.com/gitea/act v0.243.1/go.mod h1:iLHCXqOPUElA2nSyHo4wtxSmvdkym3WU7CkP3AxF39Q=
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4= gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681 h1:MMSPgnVULVwV9kEBgvyEUhC9v/uviZ55hPJEMjpbNR4=
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc= gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0= gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
@@ -402,8 +402,9 @@ github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e/go.mod h1:RCMrTZv
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.4.0 h1:Vaw7LaSTRJOUric7pe4vnzBSgyuf2KrLsu2Y4ZpQBDE=
github.com/go-git/go-billy/v5 v5.4.0/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= github.com/go-git/go-billy/v5 v5.4.0/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4=
github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg=
github.com/go-git/go-git-fixtures/v4 v4.3.1 h1:y5z6dd3qi8Hl+stezc8p3JxDkoTRqMAlKnXHuzrfjTQ= github.com/go-git/go-git-fixtures/v4 v4.3.1 h1:y5z6dd3qi8Hl+stezc8p3JxDkoTRqMAlKnXHuzrfjTQ=
github.com/go-git/go-git-fixtures/v4 v4.3.1/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= github.com/go-git/go-git-fixtures/v4 v4.3.1/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo=
github.com/go-git/go-git/v5 v5.5.2 h1:v8lgZa5k9ylUw+OR/roJHTxR4QItsNFI5nKtAXFuynw= github.com/go-git/go-git/v5 v5.5.2 h1:v8lgZa5k9ylUw+OR/roJHTxR4QItsNFI5nKtAXFuynw=
@@ -411,8 +412,6 @@ github.com/go-git/go-git/v5 v5.5.2/go.mod h1:BE5hUJ5yaV2YMxhmaP4l6RBQ08kMxKSPD4B
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
@@ -791,7 +790,7 @@ github.com/jhillyerd/enmime v0.10.1 h1:3VP8gFhK7R948YJBrna5bOgnTXEuPAoICo79kKkBK
github.com/jhillyerd/enmime v0.10.1/go.mod h1:Qpe8EEemJMFAF8+NZoWdpXvK2Yb9dRF0k/z6mkcDHsA= github.com/jhillyerd/enmime v0.10.1/go.mod h1:Qpe8EEemJMFAF8+NZoWdpXvK2Yb9dRF0k/z6mkcDHsA=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
@@ -1099,8 +1098,8 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rhysd/actionlint v1.6.22 h1:cAEf2PGNwJXhdcTVF2xS/0ORqWS+ueUHwjQYsqFsGSk= github.com/rhysd/actionlint v1.6.23 h1:041VOXgZddfvSJa9Il+WT3Iwuo/j0Nmu4bhpAScrds4=
github.com/rhysd/actionlint v1.6.22/go.mod h1:gIKOdxtV40mBOcD0ZR8EBa8NqjEXToAZioroS3oedMg= github.com/rhysd/actionlint v1.6.23/go.mod h1:o5qc1K3I9taGMBhL7mVkpRd64hx3YqI+3t8ewGfYXfE=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
@@ -1501,8 +1500,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1610,14 +1609,14 @@ golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -126,6 +126,17 @@ func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {
return nil, fmt.Errorf("event %s is not a push event", run.Event) return nil, fmt.Errorf("event %s is not a push event", run.Event)
} }
func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, error) {
if run.Event == webhook_module.HookEventPullRequest {
var payload api.PullRequestPayload
if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil {
return nil, err
}
return &payload, nil
}
return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
}
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error { func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
_, err := db.GetEngine(ctx).ID(repo.ID). _, err := db.GetEngine(ctx).ID(repo.ID).
SetExpr("num_action_runs", SetExpr("num_action_runs",
@@ -194,6 +205,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
if len(needs) > 0 { if len(needs) > 0 {
status = StatusBlocked status = StatusBlocked
} }
job.Name, _ = util.SplitStringAtByteN(job.Name, 255)
runJobs = append(runJobs, &ActionRunJob{ runJobs = append(runJobs, &ActionRunJob{
RunID: run.ID, RunID: run.ID,
RepoID: run.RepoID, RepoID: run.RepoID,

View File

@@ -298,8 +298,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
if len(workflowJob.Steps) > 0 { if len(workflowJob.Steps) > 0 {
steps := make([]*ActionTaskStep, len(workflowJob.Steps)) steps := make([]*ActionTaskStep, len(workflowJob.Steps))
for i, v := range workflowJob.Steps { for i, v := range workflowJob.Steps {
name, _ := util.SplitStringAtByteN(v.String(), 255)
steps[i] = &ActionTaskStep{ steps[i] = &ActionTaskStep{
Name: v.String(), Name: name,
TaskID: task.ID, TaskID: task.ID,
Index: int64(i), Index: int64(i),
RepoID: task.RepoID, RepoID: task.RepoID,

View File

@@ -99,7 +99,7 @@ func (a *Action) TableIndices() []*schemas.Index {
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted") actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
indices := []*schemas.Index{actUserIndex, repoIndex} indices := []*schemas.Index{actUserIndex, repoIndex}
if setting.Database.UsePostgreSQL { if setting.Database.Type.IsPostgreSQL() {
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType) cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
cudIndex.AddColumn("created_unix", "user_id", "is_deleted") cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
indices = append(indices, cudIndex) indices = append(indices, cudIndex)
@@ -640,7 +640,7 @@ func DeleteIssueActions(ctx context.Context, repoID, issueID int64) error {
// CountActionCreatedUnixString count actions where created_unix is an empty string // CountActionCreatedUnixString count actions where created_unix is an empty string
func CountActionCreatedUnixString(ctx context.Context) (int64, error) { func CountActionCreatedUnixString(ctx context.Context) (int64, error) {
if setting.Database.UseSQLite3 { if setting.Database.Type.IsSQLite3() {
return db.GetEngine(ctx).Where(`created_unix = ""`).Count(new(Action)) return db.GetEngine(ctx).Where(`created_unix = ""`).Count(new(Action))
} }
return 0, nil return 0, nil
@@ -648,7 +648,7 @@ func CountActionCreatedUnixString(ctx context.Context) (int64, error) {
// FixActionCreatedUnixString set created_unix to zero if it is an empty string // FixActionCreatedUnixString set created_unix to zero if it is an empty string
func FixActionCreatedUnixString(ctx context.Context) (int64, error) { func FixActionCreatedUnixString(ctx context.Context) (int64, error) {
if setting.Database.UseSQLite3 { if setting.Database.Type.IsSQLite3() {
res, err := db.GetEngine(ctx).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ""`) res, err := db.GetEngine(ctx).Exec(`UPDATE action SET created_unix = 0 WHERE created_unix = ""`)
if err != nil { if err != nil {
return 0, err return 0, err

View File

@@ -234,7 +234,7 @@ func TestGetFeedsCorrupted(t *testing.T) {
} }
func TestConsistencyUpdateAction(t *testing.T) { func TestConsistencyUpdateAction(t *testing.T) {
if !setting.Database.UseSQLite3 { if !setting.Database.Type.IsSQLite3() {
t.Skip("Test is only for SQLite database.") t.Skip("Test is only for SQLite database.")
} }
assert.NoError(t, unittest.PrepareTestDatabase()) assert.NoError(t, unittest.PrepareTestDatabase())

View File

@@ -39,9 +39,9 @@ func getUserHeatmapData(user *user_model.User, team *organization.Team, doer *us
groupBy := "created_unix / 900 * 900" groupBy := "created_unix / 900 * 900"
groupByName := "timestamp" // We need this extra case because mssql doesn't allow grouping by alias groupByName := "timestamp" // We need this extra case because mssql doesn't allow grouping by alias
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
groupBy = "created_unix DIV 900 * 900" groupBy = "created_unix DIV 900 * 900"
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
groupByName = groupBy groupByName = groupBy
} }

View File

@@ -153,7 +153,7 @@ func generateEmailAvatarLink(ctx context.Context, email string, size int, final
return DefaultAvatarLink() return DefaultAvatarLink()
} }
enableFederatedAvatar := system_model.GetSettingBool(ctx, system_model.KeyPictureEnableFederatedAvatar) enableFederatedAvatar := system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureEnableFederatedAvatar)
var err error var err error
if enableFederatedAvatar && system_model.LibravatarService != nil { if enableFederatedAvatar && system_model.LibravatarService != nil {
@@ -174,7 +174,7 @@ func generateEmailAvatarLink(ctx context.Context, email string, size int, final
return urlStr return urlStr
} }
disableGravatar := system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar) disableGravatar := system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
if !disableGravatar { if !disableGravatar {
// copy GravatarSourceURL, because we will modify its Path. // copy GravatarSourceURL, because we will modify its Path.
avatarURLCopy := *system_model.GravatarSourceURL avatarURLCopy := *system_model.GravatarSourceURL

View File

@@ -28,7 +28,7 @@ func enableGravatar(t *testing.T) {
err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false") err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false")
assert.NoError(t, err) assert.NoError(t, err)
setting.GravatarSource = gravatarSource setting.GravatarSource = gravatarSource
err = system_model.Init() err = system_model.Init(db.DefaultContext)
assert.NoError(t, err) assert.NoError(t, err)
} }

View File

@@ -15,7 +15,7 @@ import (
// BuildCaseInsensitiveLike returns a condition to check if the given value is like the given key case-insensitively. // BuildCaseInsensitiveLike returns a condition to check if the given value is like the given key case-insensitively.
// Handles especially SQLite correctly as UPPER there only transforms ASCII letters. // Handles especially SQLite correctly as UPPER there only transforms ASCII letters.
func BuildCaseInsensitiveLike(key, value string) builder.Cond { func BuildCaseInsensitiveLike(key, value string) builder.Cond {
if setting.Database.UseSQLite3 { if setting.Database.Type.IsSQLite3() {
return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)} return builder.Like{"UPPER(" + key + ")", util.ToUpperASCII(value)}
} }
return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)} return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)}

View File

@@ -100,12 +100,12 @@ func newXORMEngine() (*xorm.Engine, error) {
var engine *xorm.Engine var engine *xorm.Engine
if setting.Database.UsePostgreSQL && len(setting.Database.Schema) > 0 { if setting.Database.Type.IsPostgreSQL() && len(setting.Database.Schema) > 0 {
// OK whilst we sort out our schema issues - create a schema aware postgres // OK whilst we sort out our schema issues - create a schema aware postgres
registerPostgresSchemaDriver() registerPostgresSchemaDriver()
engine, err = xorm.NewEngine("postgresschema", connStr) engine, err = xorm.NewEngine("postgresschema", connStr)
} else { } else {
engine, err = xorm.NewEngine(setting.Database.Type, connStr) engine, err = xorm.NewEngine(setting.Database.Type.String(), connStr)
} }
if err != nil { if err != nil {

View File

@@ -73,7 +73,7 @@ func postgresGetNextResourceIndex(ctx context.Context, tableName string, groupID
// GetNextResourceIndex generates a resource index, it must run in the same transaction where the resource is created // GetNextResourceIndex generates a resource index, it must run in the same transaction where the resource is created
func GetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) { func GetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) {
if setting.Database.UsePostgreSQL { if setting.Database.Type.IsPostgreSQL() {
return postgresGetNextResourceIndex(ctx, tableName, groupID) return postgresGetNextResourceIndex(ctx, tableName, groupID)
} }

View File

@@ -134,7 +134,7 @@ func Find[T any](ctx context.Context, opts FindOptions, objects *[]T) error {
if !opts.IsListAll() { if !opts.IsListAll() {
sess.Limit(opts.GetSkipTake()) sess.Limit(opts.GetSkipTake())
} }
return sess.Find(&objects) return sess.Find(objects)
} }
// Count represents a common count function which accept an options interface // Count represents a common count function which accept an options interface
@@ -148,5 +148,5 @@ func FindAndCount[T any](ctx context.Context, opts FindOptions, objects *[]T) (i
if !opts.IsListAll() { if !opts.IsListAll() {
sess.Limit(opts.GetSkipTake()) sess.Limit(opts.GetSkipTake())
} }
return sess.FindAndCount(&objects) return sess.FindAndCount(objects)
} }

48
models/db/list_test.go Normal file
View File

@@ -0,0 +1,48 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package db_test
import (
"testing"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
"github.com/stretchr/testify/assert"
"xorm.io/builder"
)
type mockListOptions struct {
db.ListOptions
}
func (opts *mockListOptions) IsListAll() bool {
return true
}
func (opts *mockListOptions) ToConds() builder.Cond {
return builder.NewCond()
}
func TestFind(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
xe := unittest.GetXORMEngine()
assert.NoError(t, xe.Sync(&repo_model.RepoUnit{}))
opts := mockListOptions{}
var repoUnits []repo_model.RepoUnit
err := db.Find(db.DefaultContext, &opts, &repoUnits)
assert.NoError(t, err)
assert.EqualValues(t, 83, len(repoUnits))
cnt, err := db.Count(db.DefaultContext, &opts, new(repo_model.RepoUnit))
assert.NoError(t, err)
assert.EqualValues(t, 83, cnt)
repoUnits = make([]repo_model.RepoUnit, 0, 10)
newCnt, err := db.FindAndCount(db.DefaultContext, &opts, &repoUnits)
assert.NoError(t, err)
assert.EqualValues(t, cnt, newCnt)
}

View File

@@ -13,7 +13,7 @@ import (
// CountBadSequences looks for broken sequences from recreate-table mistakes // CountBadSequences looks for broken sequences from recreate-table mistakes
func CountBadSequences(_ context.Context) (int64, error) { func CountBadSequences(_ context.Context) (int64, error) {
if !setting.Database.UsePostgreSQL { if !setting.Database.Type.IsPostgreSQL() {
return 0, nil return 0, nil
} }
@@ -34,7 +34,7 @@ func CountBadSequences(_ context.Context) (int64, error) {
// FixBadSequences fixes for broken sequences from recreate-table mistakes // FixBadSequences fixes for broken sequences from recreate-table mistakes
func FixBadSequences(_ context.Context) error { func FixBadSequences(_ context.Context) error {
if !setting.Database.UsePostgreSQL { if !setting.Database.Type.IsPostgreSQL() {
return nil return nil
} }

View File

@@ -25,7 +25,7 @@
fork_id: 0 fork_id: 0
is_template: false is_template: false
template_id: 0 template_id: 0
size: 6708 size: 7028
is_fsck_enabled: true is_fsck_enabled: true
close_issues_via_commit_in_any_branch: false close_issues_via_commit_in_any_branch: false

View File

@@ -65,7 +65,7 @@ func postgresGetCommitStatusIndex(ctx context.Context, repoID int64, sha string)
// GetNextCommitStatusIndex retried 3 times to generate a resource index // GetNextCommitStatusIndex retried 3 times to generate a resource index
func GetNextCommitStatusIndex(ctx context.Context, repoID int64, sha string) (int64, error) { func GetNextCommitStatusIndex(ctx context.Context, repoID int64, sha string) (int64, error) {
if setting.Database.UsePostgreSQL { if setting.Database.Type.IsPostgreSQL() {
return postgresGetCommitStatusIndex(ctx, repoID, sha) return postgresGetCommitStatusIndex(ctx, repoID, sha)
} }

View File

@@ -7,12 +7,12 @@ package issues
import ( import (
"context" "context"
"fmt" "fmt"
"regexp"
"strconv" "strconv"
"strings" "strings"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/label"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/util"
@@ -78,9 +78,6 @@ func (err ErrLabelNotExist) Unwrap() error {
return util.ErrNotExist return util.ErrNotExist
} }
// LabelColorPattern is a regexp witch can validate LabelColor
var LabelColorPattern = regexp.MustCompile("^#?(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$")
// Label represents a label of repository for issues. // Label represents a label of repository for issues.
type Label struct { type Label struct {
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
@@ -109,12 +106,12 @@ func init() {
} }
// CalOpenIssues sets the number of open issues of a label based on the already stored number of closed issues. // CalOpenIssues sets the number of open issues of a label based on the already stored number of closed issues.
func (label *Label) CalOpenIssues() { func (l *Label) CalOpenIssues() {
label.NumOpenIssues = label.NumIssues - label.NumClosedIssues l.NumOpenIssues = l.NumIssues - l.NumClosedIssues
} }
// CalOpenOrgIssues calculates the open issues of a label for a specific repo // CalOpenOrgIssues calculates the open issues of a label for a specific repo
func (label *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64) { func (l *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64) {
counts, _ := CountIssuesByRepo(ctx, &IssuesOptions{ counts, _ := CountIssuesByRepo(ctx, &IssuesOptions{
RepoID: repoID, RepoID: repoID,
LabelIDs: []int64{labelID}, LabelIDs: []int64{labelID},
@@ -122,22 +119,22 @@ func (label *Label) CalOpenOrgIssues(ctx context.Context, repoID, labelID int64)
}) })
for _, count := range counts { for _, count := range counts {
label.NumOpenRepoIssues += count l.NumOpenRepoIssues += count
} }
} }
// LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked // LoadSelectedLabelsAfterClick calculates the set of selected labels when a label is clicked
func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64, currentSelectedExclusiveScopes []string) { func (l *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64, currentSelectedExclusiveScopes []string) {
var labelQuerySlice []string var labelQuerySlice []string
labelSelected := false labelSelected := false
labelID := strconv.FormatInt(label.ID, 10) labelID := strconv.FormatInt(l.ID, 10)
labelScope := label.ExclusiveScope() labelScope := l.ExclusiveScope()
for i, s := range currentSelectedLabels { for i, s := range currentSelectedLabels {
if s == label.ID { if s == l.ID {
labelSelected = true labelSelected = true
} else if -s == label.ID { } else if -s == l.ID {
labelSelected = true labelSelected = true
label.IsExcluded = true l.IsExcluded = true
} else if s != 0 { } else if s != 0 {
// Exclude other labels in the same scope from selection // Exclude other labels in the same scope from selection
if s < 0 || labelScope == "" || labelScope != currentSelectedExclusiveScopes[i] { if s < 0 || labelScope == "" || labelScope != currentSelectedExclusiveScopes[i] {
@@ -148,23 +145,23 @@ func (label *Label) LoadSelectedLabelsAfterClick(currentSelectedLabels []int64,
if !labelSelected { if !labelSelected {
labelQuerySlice = append(labelQuerySlice, labelID) labelQuerySlice = append(labelQuerySlice, labelID)
} }
label.IsSelected = labelSelected l.IsSelected = labelSelected
label.QueryString = strings.Join(labelQuerySlice, ",") l.QueryString = strings.Join(labelQuerySlice, ",")
} }
// BelongsToOrg returns true if label is an organization label // BelongsToOrg returns true if label is an organization label
func (label *Label) BelongsToOrg() bool { func (l *Label) BelongsToOrg() bool {
return label.OrgID > 0 return l.OrgID > 0
} }
// BelongsToRepo returns true if label is a repository label // BelongsToRepo returns true if label is a repository label
func (label *Label) BelongsToRepo() bool { func (l *Label) BelongsToRepo() bool {
return label.RepoID > 0 return l.RepoID > 0
} }
// Get color as RGB values in 0..255 range // Get color as RGB values in 0..255 range
func (label *Label) ColorRGB() (float64, float64, float64, error) { func (l *Label) ColorRGB() (float64, float64, float64, error) {
color, err := strconv.ParseUint(label.Color[1:], 16, 64) color, err := strconv.ParseUint(l.Color[1:], 16, 64)
if err != nil { if err != nil {
return 0, 0, 0, err return 0, 0, 0, err
} }
@@ -176,9 +173,9 @@ func (label *Label) ColorRGB() (float64, float64, float64, error) {
} }
// Determine if label text should be light or dark to be readable on background color // Determine if label text should be light or dark to be readable on background color
func (label *Label) UseLightTextColor() bool { func (l *Label) UseLightTextColor() bool {
if strings.HasPrefix(label.Color, "#") { if strings.HasPrefix(l.Color, "#") {
if r, g, b, err := label.ColorRGB(); err == nil { if r, g, b, err := l.ColorRGB(); err == nil {
// Perceived brightness from: https://www.w3.org/TR/AERT/#color-contrast // Perceived brightness from: https://www.w3.org/TR/AERT/#color-contrast
// In the future WCAG 3 APCA may be a better solution // In the future WCAG 3 APCA may be a better solution
brightness := (0.299*r + 0.587*g + 0.114*b) / 255 brightness := (0.299*r + 0.587*g + 0.114*b) / 255
@@ -190,40 +187,26 @@ func (label *Label) UseLightTextColor() bool {
} }
// Return scope substring of label name, or empty string if none exists // Return scope substring of label name, or empty string if none exists
func (label *Label) ExclusiveScope() string { func (l *Label) ExclusiveScope() string {
if !label.Exclusive { if !l.Exclusive {
return "" return ""
} }
lastIndex := strings.LastIndex(label.Name, "/") lastIndex := strings.LastIndex(l.Name, "/")
if lastIndex == -1 || lastIndex == 0 || lastIndex == len(label.Name)-1 { if lastIndex == -1 || lastIndex == 0 || lastIndex == len(l.Name)-1 {
return "" return ""
} }
return label.Name[:lastIndex] return l.Name[:lastIndex]
} }
// NewLabel creates a new label // NewLabel creates a new label
func NewLabel(ctx context.Context, label *Label) error { func NewLabel(ctx context.Context, l *Label) error {
if !LabelColorPattern.MatchString(label.Color) { color, err := label.NormalizeColor(l.Color)
return fmt.Errorf("bad color code: %s", label.Color) if err != nil {
return err
} }
l.Color = color
// normalize case return db.Insert(ctx, l)
label.Color = strings.ToLower(label.Color)
// add leading hash
if label.Color[0] != '#' {
label.Color = "#" + label.Color
}
// convert 3-character shorthand into 6-character version
if len(label.Color) == 4 {
r := label.Color[1]
g := label.Color[2]
b := label.Color[3]
label.Color = fmt.Sprintf("#%c%c%c%c%c%c", r, r, g, g, b, b)
}
return db.Insert(ctx, label)
} }
// NewLabels creates new labels // NewLabels creates new labels
@@ -234,11 +217,14 @@ func NewLabels(labels ...*Label) error {
} }
defer committer.Close() defer committer.Close()
for _, label := range labels { for _, l := range labels {
if !LabelColorPattern.MatchString(label.Color) { color, err := label.NormalizeColor(l.Color)
return fmt.Errorf("bad color code: %s", label.Color) if err != nil {
return err
} }
if err := db.Insert(ctx, label); err != nil { l.Color = color
if err := db.Insert(ctx, l); err != nil {
return err return err
} }
} }
@@ -247,15 +233,18 @@ func NewLabels(labels ...*Label) error {
// UpdateLabel updates label information. // UpdateLabel updates label information.
func UpdateLabel(l *Label) error { func UpdateLabel(l *Label) error {
if !LabelColorPattern.MatchString(l.Color) { color, err := label.NormalizeColor(l.Color)
return fmt.Errorf("bad color code: %s", l.Color) if err != nil {
return err
} }
l.Color = color
return updateLabelCols(db.DefaultContext, l, "name", "description", "color", "exclusive") return updateLabelCols(db.DefaultContext, l, "name", "description", "color", "exclusive")
} }
// DeleteLabel delete a label // DeleteLabel delete a label
func DeleteLabel(id, labelID int64) error { func DeleteLabel(id, labelID int64) error {
label, err := GetLabelByID(db.DefaultContext, labelID) l, err := GetLabelByID(db.DefaultContext, labelID)
if err != nil { if err != nil {
if IsErrLabelNotExist(err) { if IsErrLabelNotExist(err) {
return nil return nil
@@ -271,10 +260,10 @@ func DeleteLabel(id, labelID int64) error {
sess := db.GetEngine(ctx) sess := db.GetEngine(ctx)
if label.BelongsToOrg() && label.OrgID != id { if l.BelongsToOrg() && l.OrgID != id {
return nil return nil
} }
if label.BelongsToRepo() && label.RepoID != id { if l.BelongsToRepo() && l.RepoID != id {
return nil return nil
} }
@@ -682,14 +671,14 @@ func newIssueLabels(ctx context.Context, issue *Issue, labels []*Label, doer *us
if err = issue.LoadRepo(ctx); err != nil { if err = issue.LoadRepo(ctx); err != nil {
return err return err
} }
for _, label := range labels { for _, l := range labels {
// Don't add already present labels and invalid labels // Don't add already present labels and invalid labels
if HasIssueLabel(ctx, issue.ID, label.ID) || if HasIssueLabel(ctx, issue.ID, l.ID) ||
(label.RepoID != issue.RepoID && label.OrgID != issue.Repo.OwnerID) { (l.RepoID != issue.RepoID && l.OrgID != issue.Repo.OwnerID) {
continue continue
} }
if err = newIssueLabel(ctx, issue, label, doer); err != nil { if err = newIssueLabel(ctx, issue, l, doer); err != nil {
return fmt.Errorf("newIssueLabel: %w", err) return fmt.Errorf("newIssueLabel: %w", err)
} }
} }
@@ -778,7 +767,7 @@ func CountOrphanedLabels(ctx context.Context) (int64, error) {
norepo, err := db.GetEngine(ctx).Table("label"). norepo, err := db.GetEngine(ctx).Table("label").
Where(builder.And( Where(builder.And(
builder.Gt{"repo_id": 0}, builder.Gt{"repo_id": 0},
builder.NotIn("repo_id", builder.Select("id").From("repository")), builder.NotIn("repo_id", builder.Select("id").From("`repository`")),
)). )).
Count() Count()
if err != nil { if err != nil {
@@ -788,7 +777,7 @@ func CountOrphanedLabels(ctx context.Context) (int64, error) {
noorg, err := db.GetEngine(ctx).Table("label"). noorg, err := db.GetEngine(ctx).Table("label").
Where(builder.And( Where(builder.And(
builder.Gt{"org_id": 0}, builder.Gt{"org_id": 0},
builder.NotIn("org_id", builder.Select("id").From("user")), builder.NotIn("org_id", builder.Select("id").From("`user`")),
)). )).
Count() Count()
if err != nil { if err != nil {
@@ -809,7 +798,7 @@ func DeleteOrphanedLabels(ctx context.Context) error {
if _, err := db.GetEngine(ctx). if _, err := db.GetEngine(ctx).
Where(builder.And( Where(builder.And(
builder.Gt{"repo_id": 0}, builder.Gt{"repo_id": 0},
builder.NotIn("repo_id", builder.Select("id").From("repository")), builder.NotIn("repo_id", builder.Select("id").From("`repository`")),
)). )).
Delete(Label{}); err != nil { Delete(Label{}); err != nil {
return err return err
@@ -819,7 +808,7 @@ func DeleteOrphanedLabels(ctx context.Context) error {
if _, err := db.GetEngine(ctx). if _, err := db.GetEngine(ctx).
Where(builder.And( Where(builder.And(
builder.Gt{"org_id": 0}, builder.Gt{"org_id": 0},
builder.NotIn("org_id", builder.Select("id").From("user")), builder.NotIn("org_id", builder.Select("id").From("`user`")),
)). )).
Delete(Label{}); err != nil { Delete(Label{}); err != nil {
return err return err

View File

@@ -15,8 +15,6 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
// TODO TestGetLabelTemplateFile
func TestLabel_CalOpenIssues(t *testing.T) { func TestLabel_CalOpenIssues(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase()) assert.NoError(t, unittest.PrepareTestDatabase())
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1}) label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})

View File

@@ -52,13 +52,16 @@ func listPullRequestStatement(baseRepoID int64, opts *PullRequestsOptions) (*xor
// GetUnmergedPullRequestsByHeadInfo returns all pull requests that are open and has not been merged // GetUnmergedPullRequestsByHeadInfo returns all pull requests that are open and has not been merged
// by given head information (repo and branch). // by given head information (repo and branch).
func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string) ([]*PullRequest, error) { // arg `includeClosed` controls whether the SQL returns closed PRs
func GetUnmergedPullRequestsByHeadInfo(repoID int64, branch string, includeClosed bool) ([]*PullRequest, error) {
prs := make([]*PullRequest, 0, 2) prs := make([]*PullRequest, 0, 2)
return prs, db.GetEngine(db.DefaultContext). sess := db.GetEngine(db.DefaultContext).
Where("head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?",
repoID, branch, false, false, PullRequestFlowGithub).
Join("INNER", "issue", "issue.id = pull_request.issue_id"). Join("INNER", "issue", "issue.id = pull_request.issue_id").
Find(&prs) Where("head_repo_id = ? AND head_branch = ? AND has_merged = ? AND flow = ?", repoID, branch, false, PullRequestFlowGithub)
if !includeClosed {
sess.Where("issue.is_closed = ?", false)
}
return prs, sess.Find(&prs)
} }
// CanMaintainerWriteToBranch check whether user is a maintainer and could write to the branch // CanMaintainerWriteToBranch check whether user is a maintainer and could write to the branch
@@ -71,7 +74,7 @@ func CanMaintainerWriteToBranch(p access_model.Permission, branch string, user *
return false return false
} }
prs, err := GetUnmergedPullRequestsByHeadInfo(p.Units[0].RepoID, branch) prs, err := GetUnmergedPullRequestsByHeadInfo(p.Units[0].RepoID, branch, false)
if err != nil { if err != nil {
return false return false
} }
@@ -111,6 +114,7 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ
return prs, db.GetEngine(db.DefaultContext). return prs, db.GetEngine(db.DefaultContext).
Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?", Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?",
repoID, branch, false, false). repoID, branch, false, false).
OrderBy("issue.updated_unix DESC").
Join("INNER", "issue", "issue.id=pull_request.issue_id"). Join("INNER", "issue", "issue.id=pull_request.issue_id").
Find(&prs) Find(&prs)
} }

View File

@@ -118,7 +118,7 @@ func TestHasUnmergedPullRequestsByHeadInfo(t *testing.T) {
func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) { func TestGetUnmergedPullRequestsByHeadInfo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase()) assert.NoError(t, unittest.PrepareTestDatabase())
prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(1, "branch2") prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(1, "branch2", false)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, prs, 1) assert.Len(t, prs, 1)
for _, pr := range prs { for _, pr := range prs {

View File

@@ -89,7 +89,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
hasID = hasID || (column.IsPrimaryKey && column.IsAutoIncrement) hasID = hasID || (column.IsPrimaryKey && column.IsAutoIncrement)
} }
if hasID && setting.Database.UseMSSQL { if hasID && setting.Database.Type.IsMSSQL() {
if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` ON", tempTableName)); err != nil { if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` ON", tempTableName)); err != nil {
log.Error("Unable to set identity insert for table %s. Error: %v", tempTableName, err) log.Error("Unable to set identity insert for table %s. Error: %v", tempTableName, err)
return err return err
@@ -143,7 +143,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
return err return err
} }
if hasID && setting.Database.UseMSSQL { if hasID && setting.Database.Type.IsMSSQL() {
if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` OFF", tempTableName)); err != nil { if _, err := sess.Exec(fmt.Sprintf("SET IDENTITY_INSERT `%s` OFF", tempTableName)); err != nil {
log.Error("Unable to switch off identity insert for table %s. Error: %v", tempTableName, err) log.Error("Unable to switch off identity insert for table %s. Error: %v", tempTableName, err)
return err return err
@@ -151,7 +151,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
} }
switch { switch {
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
// SQLite will drop all the constraints on the old table // SQLite will drop all the constraints on the old table
if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil { if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil {
log.Error("Unable to drop old table %s. Error: %v", tableName, err) log.Error("Unable to drop old table %s. Error: %v", tableName, err)
@@ -178,7 +178,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
return err return err
} }
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
// MySQL will drop all the constraints on the old table // MySQL will drop all the constraints on the old table
if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil { if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil {
log.Error("Unable to drop old table %s. Error: %v", tableName, err) log.Error("Unable to drop old table %s. Error: %v", tableName, err)
@@ -205,7 +205,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
log.Error("Unable to recreate uniques on table %s. Error: %v", tableName, err) log.Error("Unable to recreate uniques on table %s. Error: %v", tableName, err)
return err return err
} }
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
var originalSequences []string var originalSequences []string
type sequenceData struct { type sequenceData struct {
LastValue int `xorm:"'last_value'"` LastValue int `xorm:"'last_value'"`
@@ -296,7 +296,7 @@ func RecreateTable(sess *xorm.Session, bean interface{}) error {
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
// MSSQL will drop all the constraints on the old table // MSSQL will drop all the constraints on the old table
if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil { if _, err := sess.Exec(fmt.Sprintf("DROP TABLE `%s`", tableName)); err != nil {
log.Error("Unable to drop old table %s. Error: %v", tableName, err) log.Error("Unable to drop old table %s. Error: %v", tableName, err)
@@ -323,7 +323,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
// TODO: This will not work if there are foreign keys // TODO: This will not work if there are foreign keys
switch { switch {
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
// First drop the indexes on the columns // First drop the indexes on the columns
res, errIndex := sess.Query(fmt.Sprintf("PRAGMA index_list(`%s`)", tableName)) res, errIndex := sess.Query(fmt.Sprintf("PRAGMA index_list(`%s`)", tableName))
if errIndex != nil { if errIndex != nil {
@@ -405,7 +405,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
return err return err
} }
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
cols := "" cols := ""
for _, col := range columnNames { for _, col := range columnNames {
if cols != "" { if cols != "" {
@@ -416,7 +416,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil {
return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err)
} }
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
// Drop indexes on columns first // Drop indexes on columns first
sql := fmt.Sprintf("SHOW INDEX FROM %s WHERE column_name IN ('%s')", tableName, strings.Join(columnNames, "','")) sql := fmt.Sprintf("SHOW INDEX FROM %s WHERE column_name IN ('%s')", tableName, strings.Join(columnNames, "','"))
res, err := sess.Query(sql) res, err := sess.Query(sql)
@@ -444,7 +444,7 @@ func DropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil {
return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err)
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
cols := "" cols := ""
for _, col := range columnNames { for _, col := range columnNames {
if cols != "" { if cols != "" {
@@ -543,13 +543,13 @@ func newXORMEngine() (*xorm.Engine, error) {
func deleteDB() error { func deleteDB() error {
switch { switch {
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
if err := util.Remove(setting.Database.Path); err != nil { if err := util.Remove(setting.Database.Path); err != nil {
return err return err
} }
return os.MkdirAll(path.Dir(setting.Database.Path), os.ModePerm) return os.MkdirAll(path.Dir(setting.Database.Path), os.ModePerm)
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/", db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/",
setting.Database.User, setting.Database.Passwd, setting.Database.Host)) setting.Database.User, setting.Database.Passwd, setting.Database.Host))
if err != nil { if err != nil {
@@ -565,7 +565,7 @@ func deleteDB() error {
return err return err
} }
return nil return nil
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s",
setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode)) setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode))
if err != nil { if err != nil {
@@ -612,7 +612,7 @@ func deleteDB() error {
} }
return nil return nil
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
host, port := setting.ParseMSSQLHostPort(setting.Database.Host) host, port := setting.ParseMSSQLHostPort(setting.Database.Host)
db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
host, port, "master", setting.Database.User, setting.Database.Passwd)) host, port, "master", setting.Database.User, setting.Database.Passwd))

View File

@@ -4,7 +4,6 @@
org_id: 0 org_id: 0
name: label1 name: label1
color: '#abcdef' color: '#abcdef'
exclusive: false
num_issues: 2 num_issues: 2
num_closed_issues: 0 num_closed_issues: 0
@@ -14,7 +13,6 @@
org_id: 0 org_id: 0
name: label2 name: label2
color: '#000000' color: '#000000'
exclusive: false
num_issues: 1 num_issues: 1
num_closed_issues: 1 num_closed_issues: 1
- -
@@ -23,7 +21,6 @@
org_id: 3 org_id: 3
name: orglabel3 name: orglabel3
color: '#abcdef' color: '#abcdef'
exclusive: false
num_issues: 0 num_issues: 0
num_closed_issues: 0 num_closed_issues: 0
@@ -33,7 +30,6 @@
org_id: 3 org_id: 3
name: orglabel4 name: orglabel4
color: '#000000' color: '#000000'
exclusive: false
num_issues: 1 num_issues: 1
num_closed_issues: 0 num_closed_issues: 0
@@ -43,6 +39,5 @@
org_id: 0 org_id: 0
name: pull-test-label name: pull-test-label
color: '#000000' color: '#000000'
exclusive: false
num_issues: 0 num_issues: 0
num_closed_issues: 0 num_closed_issues: 0

View File

@@ -13,9 +13,9 @@ func PrependRefsHeadsToIssueRefs(x *xorm.Engine) error {
var query string var query string
switch { switch {
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" query = "UPDATE `issue` SET `ref` = 'refs/heads/' + `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';" query = "UPDATE `issue` SET `ref` = CONCAT('refs/heads/', `ref`) WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%';"
default: default:
query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'" query = "UPDATE `issue` SET `ref` = 'refs/heads/' || `ref` WHERE `ref` IS NOT NULL AND `ref` <> '' AND `ref` NOT LIKE 'refs/%'"

View File

@@ -41,7 +41,7 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
// Delete language stat statuses // Delete language stat statuses
truncExpr := "TRUNCATE TABLE" truncExpr := "TRUNCATE TABLE"
if setting.Database.UseSQLite3 { if setting.Database.Type.IsSQLite3() {
truncExpr = "DELETE FROM" truncExpr = "DELETE FROM"
} }

View File

@@ -21,7 +21,7 @@ func IncreaseLanguageField(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseSQLite3 { if setting.Database.Type.IsSQLite3() {
// SQLite maps VARCHAR to TEXT without size so we're done // SQLite maps VARCHAR to TEXT without size so we're done
return nil return nil
} }
@@ -41,11 +41,11 @@ func IncreaseLanguageField(x *xorm.Engine) error {
} }
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat MODIFY COLUMN language %s", sqlType)); err != nil { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat MODIFY COLUMN language %s", sqlType)); err != nil {
return err return err
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
// Yet again MSSQL just has to be awkward. // Yet again MSSQL just has to be awkward.
// Here we have to drop the constraints first and then rebuild them // Here we have to drop the constraints first and then rebuild them
constraints := make([]string, 0) constraints := make([]string, 0)
@@ -71,7 +71,7 @@ func IncreaseLanguageField(x *xorm.Engine) error {
if err := sess.CreateUniques(new(LanguageStat)); err != nil { if err := sess.CreateUniques(new(LanguageStat)); err != nil {
return err return err
} }
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language TYPE %s", sqlType)); err != nil { if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE language_stat ALTER COLUMN language TYPE %s", sqlType)); err != nil {
return err return err
} }

View File

@@ -17,13 +17,13 @@ import (
func SetDefaultPasswordToArgon2(x *xorm.Engine) error { func SetDefaultPasswordToArgon2(x *xorm.Engine) error {
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
_, err := x.Exec("ALTER TABLE `user` ALTER passwd_hash_algo SET DEFAULT 'argon2';") _, err := x.Exec("ALTER TABLE `user` ALTER passwd_hash_algo SET DEFAULT 'argon2';")
return err return err
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
_, err := x.Exec("ALTER TABLE `user` ALTER COLUMN passwd_hash_algo SET DEFAULT 'argon2';") _, err := x.Exec("ALTER TABLE `user` ALTER COLUMN passwd_hash_algo SET DEFAULT 'argon2';")
return err return err
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
// need to find the constraint and drop it, then recreate it. // need to find the constraint and drop it, then recreate it.
sess := x.NewSession() sess := x.NewSession()
defer sess.Close() defer sess.Close()
@@ -53,7 +53,7 @@ func SetDefaultPasswordToArgon2(x *xorm.Engine) error {
} }
return sess.Commit() return sess.Commit()
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
// drop through // drop through
default: default:
log.Fatal("Unrecognized DB") log.Fatal("Unrecognized DB")

View File

@@ -62,7 +62,7 @@ func UpdateCodeCommentReplies(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMSSQL { if setting.Database.Type.IsMSSQL() {
if _, err := sess.Exec(sqlSelect + " INTO #temp_comments" + sqlTail); err != nil { if _, err := sess.Exec(sqlSelect + " INTO #temp_comments" + sqlTail); err != nil {
log.Error("unable to create temporary table") log.Error("unable to create temporary table")
return err return err
@@ -72,13 +72,13 @@ func UpdateCodeCommentReplies(x *xorm.Engine) error {
comments := make([]*Comment, 0, batchSize) comments := make([]*Comment, 0, batchSize)
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
sqlCmd = sqlSelect + sqlTail + " LIMIT " + strconv.Itoa(batchSize) + ", " + strconv.Itoa(start) sqlCmd = sqlSelect + sqlTail + " LIMIT " + strconv.Itoa(batchSize) + ", " + strconv.Itoa(start)
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
fallthrough fallthrough
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
sqlCmd = sqlSelect + sqlTail + " LIMIT " + strconv.Itoa(batchSize) + " OFFSET " + strconv.Itoa(start) sqlCmd = sqlSelect + sqlTail + " LIMIT " + strconv.Itoa(batchSize) + " OFFSET " + strconv.Itoa(start)
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
sqlCmd = "SELECT TOP " + strconv.Itoa(batchSize) + " * FROM #temp_comments WHERE " + sqlCmd = "SELECT TOP " + strconv.Itoa(batchSize) + " * FROM #temp_comments WHERE " +
"(id NOT IN ( SELECT TOP " + strconv.Itoa(start) + " id FROM #temp_comments ORDER BY id )) ORDER BY id" "(id NOT IN ( SELECT TOP " + strconv.Itoa(start) + " id FROM #temp_comments ORDER BY id )) ORDER BY id"
default: default:

View File

@@ -14,7 +14,7 @@ import (
) )
func FixPostgresIDSequences(x *xorm.Engine) error { func FixPostgresIDSequences(x *xorm.Engine) error {
if !setting.Database.UsePostgreSQL { if !setting.Database.Type.IsPostgreSQL() {
return nil return nil
} }

View File

@@ -54,11 +54,11 @@ func RenameTaskErrorsToMessage(x *xorm.Engine) error {
} }
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
if _, err := sess.Exec("ALTER TABLE `task` CHANGE errors message text"); err != nil { if _, err := sess.Exec("ALTER TABLE `task` CHANGE errors message text"); err != nil {
return err return err
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
if _, err := sess.Exec("sp_rename 'task.errors', 'message', 'COLUMN'"); err != nil { if _, err := sess.Exec("sp_rename 'task.errors', 'message', 'COLUMN'"); err != nil {
return err return err
} }

View File

@@ -16,7 +16,7 @@ func AlterIssueAndCommentTextFieldsToLongText(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMySQL { if setting.Database.Type.IsMySQL() {
if _, err := sess.Exec("ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT"); err != nil { if _, err := sess.Exec("ALTER TABLE `issue` CHANGE `content` `content` LONGTEXT"); err != nil {
return err return err
} }

View File

@@ -16,7 +16,7 @@ func AlterHookTaskTextFieldsToLongText(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMySQL { if setting.Database.Type.IsMySQL() {
if _, err := sess.Exec("ALTER TABLE `hook_task` CHANGE `payload_content` `payload_content` LONGTEXT, CHANGE `request_content` `request_content` LONGTEXT, change `response_content` `response_content` LONGTEXT"); err != nil { if _, err := sess.Exec("ALTER TABLE `hook_task` CHANGE `payload_content` `payload_content` LONGTEXT, CHANGE `request_content` `request_content` LONGTEXT, change `response_content` `response_content` LONGTEXT"); err != nil {
return err return err
} }

View File

@@ -38,7 +38,7 @@ func (*improveActionTableIndicesAction) TableIndices() []*schemas.Index {
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType) actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted") actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
indices := []*schemas.Index{actUserIndex, repoIndex} indices := []*schemas.Index{actUserIndex, repoIndex}
if setting.Database.UsePostgreSQL { if setting.Database.Type.IsPostgreSQL() {
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType) cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
cudIndex.AddColumn("created_unix", "user_id", "is_deleted") cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
indices = append(indices, cudIndex) indices = append(indices, cudIndex)

View File

@@ -65,11 +65,11 @@ func RenameCredentialIDBytes(x *xorm.Engine) error {
} }
switch { switch {
case setting.Database.UseMySQL: case setting.Database.Type.IsMySQL():
if _, err := sess.Exec("ALTER TABLE `webauthn_credential` CHANGE credential_id_bytes credential_id VARBINARY(1024)"); err != nil { if _, err := sess.Exec("ALTER TABLE `webauthn_credential` CHANGE credential_id_bytes credential_id VARBINARY(1024)"); err != nil {
return err return err
} }
case setting.Database.UseMSSQL: case setting.Database.Type.IsMSSQL():
if _, err := sess.Exec("sp_rename 'webauthn_credential.credential_id_bytes', 'credential_id', 'COLUMN'"); err != nil { if _, err := sess.Exec("sp_rename 'webauthn_credential.credential_id_bytes', 'credential_id', 'COLUMN'"); err != nil {
return err return err
} }

View File

@@ -16,7 +16,7 @@ func AlterPublicGPGKeyContentFieldsToMediumText(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMySQL { if setting.Database.Type.IsMySQL() {
if _, err := sess.Exec("ALTER TABLE `gpg_key` CHANGE `content` `content` MEDIUMTEXT"); err != nil { if _, err := sess.Exec("ALTER TABLE `gpg_key` CHANGE `content` `content` MEDIUMTEXT"); err != nil {
return err return err
} }

View File

@@ -16,7 +16,7 @@ func AlterPackageVersionMetadataToLongText(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMySQL { if setting.Database.Type.IsMySQL() {
if _, err := sess.Exec("ALTER TABLE `package_version` MODIFY COLUMN `metadata_json` LONGTEXT"); err != nil { if _, err := sess.Exec("ALTER TABLE `package_version` MODIFY COLUMN `metadata_json` LONGTEXT"); err != nil {
return err return err
} }

View File

@@ -17,7 +17,7 @@ func AlterPublicGPGKeyImportContentFieldToMediumText(x *xorm.Engine) error {
return err return err
} }
if setting.Database.UseMySQL { if setting.Database.Type.IsMySQL() {
if _, err := sess.Exec("ALTER TABLE `gpg_key_import` CHANGE `content` `content` MEDIUMTEXT"); err != nil { if _, err := sess.Exec("ALTER TABLE `gpg_key_import` CHANGE `content` `content` MEDIUMTEXT"); err != nil {
return err return err
} }

View File

@@ -239,6 +239,32 @@ func (org *Organization) CustomAvatarRelativePath() string {
return org.Avatar return org.Avatar
} }
// UnitPermission returns unit permission
func (org *Organization) UnitPermission(ctx context.Context, doer *user_model.User, unitType unit.Type) perm.AccessMode {
if doer != nil {
teams, err := GetUserOrgTeams(ctx, org.ID, doer.ID)
if err != nil {
log.Error("GetUserOrgTeams: %v", err)
return perm.AccessModeNone
}
if err := teams.LoadUnits(ctx); err != nil {
log.Error("LoadUnits: %v", err)
return perm.AccessModeNone
}
if len(teams) > 0 {
return teams.UnitMaxAccess(unitType)
}
}
if org.Visibility.IsPublic() {
return perm.AccessModeRead
}
return perm.AccessModeNone
}
// CreateOrganization creates record of a new organization. // CreateOrganization creates record of a new organization.
func CreateOrganization(org *Organization, owner *user_model.User) (err error) { func CreateOrganization(org *Organization, owner *user_model.User) (err error) {
if !owner.CanCreateOrganization() { if !owner.CanCreateOrganization() {

View File

@@ -416,7 +416,7 @@ func DeleteProjectByID(ctx context.Context, id int64) error {
func DeleteProjectByRepoID(ctx context.Context, repoID int64) error { func DeleteProjectByRepoID(ctx context.Context, repoID int64) error {
switch { switch {
case setting.Database.UseSQLite3: case setting.Database.Type.IsSQLite3():
if _, err := db.GetEngine(ctx).Exec("DELETE FROM project_issue WHERE project_issue.id IN (SELECT project_issue.id FROM project_issue INNER JOIN project WHERE project.id = project_issue.project_id AND project.repo_id = ?)", repoID); err != nil { if _, err := db.GetEngine(ctx).Exec("DELETE FROM project_issue WHERE project_issue.id IN (SELECT project_issue.id FROM project_issue INNER JOIN project WHERE project.id = project_issue.project_id AND project.repo_id = ?)", repoID); err != nil {
return err return err
} }
@@ -426,7 +426,7 @@ func DeleteProjectByRepoID(ctx context.Context, repoID int64) error {
if _, err := db.GetEngine(ctx).Table("project").Where("repo_id = ? ", repoID).Delete(&Project{}); err != nil { if _, err := db.GetEngine(ctx).Table("project").Where("repo_id = ? ", repoID).Delete(&Project{}); err != nil {
return err return err
} }
case setting.Database.UsePostgreSQL: case setting.Database.Type.IsPostgreSQL():
if _, err := db.GetEngine(ctx).Exec("DELETE FROM project_issue USING project WHERE project.id = project_issue.project_id AND project.repo_id = ? ", repoID); err != nil { if _, err := db.GetEngine(ctx).Exec("DELETE FROM project_issue USING project WHERE project.id = project_issue.project_id AND project.repo_id = ? ", repoID); err != nil {
return err return err
} }

View File

@@ -39,9 +39,9 @@ import (
var ItemsPerPage = 40 var ItemsPerPage = 40
// Init initialize model // Init initialize model
func Init() error { func Init(ctx context.Context) error {
unit.LoadUnitConfig() unit.LoadUnitConfig()
return system_model.Init() return system_model.Init(ctx)
} }
// DeleteRepository deletes a repository for a user or organization. // DeleteRepository deletes a repository for a user or organization.

View File

@@ -498,7 +498,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
subQueryCond := builder.NewCond() subQueryCond := builder.NewCond()
// Topic checking. Topics are present. // Topic checking. Topics are present.
if setting.Database.UsePostgreSQL { // postgres stores the topics as json and not as text if setting.Database.Type.IsPostgreSQL() { // postgres stores the topics as json and not as text
subQueryCond = subQueryCond.Or(builder.And(builder.NotNull{"topics"}, builder.Neq{"(topics)::text": "[]"})) subQueryCond = subQueryCond.Or(builder.And(builder.NotNull{"topics"}, builder.Neq{"(topics)::text": "[]"}))
} else { } else {
subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"})) subQueryCond = subQueryCond.Or(builder.And(builder.Neq{"topics": "null"}, builder.Neq{"topics": "[]"}))

View File

@@ -79,8 +79,8 @@ func IsErrDataExpired(err error) bool {
return ok return ok
} }
// GetSettingNoCache returns specific setting without using the cache // GetSetting returns specific setting without using the cache
func GetSettingNoCache(ctx context.Context, key string) (*Setting, error) { func GetSetting(ctx context.Context, key string) (*Setting, error) {
v, err := GetSettings(ctx, []string{key}) v, err := GetSettings(ctx, []string{key})
if err != nil { if err != nil {
return nil, err return nil, err
@@ -93,11 +93,11 @@ func GetSettingNoCache(ctx context.Context, key string) (*Setting, error) {
const contextCacheKey = "system_setting" const contextCacheKey = "system_setting"
// GetSetting returns the setting value via the key // GetSettingWithCache returns the setting value via the key
func GetSetting(ctx context.Context, key string) (string, error) { func GetSettingWithCache(ctx context.Context, key string) (string, error) {
return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) { return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
return cache.GetString(genSettingCacheKey(key), func() (string, error) { return cache.GetString(genSettingCacheKey(key), func() (string, error) {
res, err := GetSettingNoCache(ctx, key) res, err := GetSetting(ctx, key)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -110,6 +110,15 @@ func GetSetting(ctx context.Context, key string) (string, error) {
// none existing keys and errors are ignored and result in false // none existing keys and errors are ignored and result in false
func GetSettingBool(ctx context.Context, key string) bool { func GetSettingBool(ctx context.Context, key string) bool {
s, _ := GetSetting(ctx, key) s, _ := GetSetting(ctx, key)
if s == nil {
return false
}
v, _ := strconv.ParseBool(s.SettingValue)
return v
}
func GetSettingWithCacheBool(ctx context.Context, key string) bool {
s, _ := GetSettingWithCache(ctx, key)
v, _ := strconv.ParseBool(s) v, _ := strconv.ParseBool(s)
return v return v
} }
@@ -120,7 +129,7 @@ func GetSettings(ctx context.Context, keys []string) (map[string]*Setting, error
keys[i] = strings.ToLower(keys[i]) keys[i] = strings.ToLower(keys[i])
} }
settings := make([]*Setting, 0, len(keys)) settings := make([]*Setting, 0, len(keys))
if err := db.GetEngine(db.DefaultContext). if err := db.GetEngine(ctx).
Where(builder.In("setting_key", keys)). Where(builder.In("setting_key", keys)).
Find(&settings); err != nil { Find(&settings); err != nil {
return nil, err return nil, err
@@ -151,9 +160,9 @@ func (settings AllSettings) GetVersion(key string) int {
} }
// GetAllSettings returns all settings from user // GetAllSettings returns all settings from user
func GetAllSettings() (AllSettings, error) { func GetAllSettings(ctx context.Context) (AllSettings, error) {
settings := make([]*Setting, 0, 5) settings := make([]*Setting, 0, 5)
if err := db.GetEngine(db.DefaultContext). if err := db.GetEngine(ctx).
Find(&settings); err != nil { Find(&settings); err != nil {
return nil, err return nil, err
} }
@@ -168,12 +177,12 @@ func GetAllSettings() (AllSettings, error) {
func DeleteSetting(ctx context.Context, setting *Setting) error { func DeleteSetting(ctx context.Context, setting *Setting) error {
cache.RemoveContextData(ctx, contextCacheKey, setting.SettingKey) cache.RemoveContextData(ctx, contextCacheKey, setting.SettingKey)
cache.Remove(genSettingCacheKey(setting.SettingKey)) cache.Remove(genSettingCacheKey(setting.SettingKey))
_, err := db.GetEngine(db.DefaultContext).Delete(setting) _, err := db.GetEngine(ctx).Delete(setting)
return err return err
} }
func SetSettingNoVersion(ctx context.Context, key, value string) error { func SetSettingNoVersion(ctx context.Context, key, value string) error {
s, err := GetSettingNoCache(ctx, key) s, err := GetSetting(ctx, key)
if IsErrSettingIsNotExist(err) { if IsErrSettingIsNotExist(err) {
return SetSetting(ctx, &Setting{ return SetSetting(ctx, &Setting{
SettingKey: key, SettingKey: key,
@@ -189,7 +198,7 @@ func SetSettingNoVersion(ctx context.Context, key, value string) error {
// SetSetting updates a users' setting for a specific key // SetSetting updates a users' setting for a specific key
func SetSetting(ctx context.Context, setting *Setting) error { func SetSetting(ctx context.Context, setting *Setting) error {
if err := upsertSettingValue(strings.ToLower(setting.SettingKey), setting.SettingValue, setting.Version); err != nil { if err := upsertSettingValue(ctx, strings.ToLower(setting.SettingKey), setting.SettingValue, setting.Version); err != nil {
return err return err
} }
@@ -205,8 +214,8 @@ func SetSetting(ctx context.Context, setting *Setting) error {
return nil return nil
} }
func upsertSettingValue(key, value string, version int) error { func upsertSettingValue(parentCtx context.Context, key, value string, version int) error {
return db.WithTx(db.DefaultContext, func(ctx context.Context) error { return db.WithTx(parentCtx, func(ctx context.Context) error {
e := db.GetEngine(ctx) e := db.GetEngine(ctx)
// here we use a general method to do a safe upsert for different databases (and most transaction levels) // here we use a general method to do a safe upsert for different databases (and most transaction levels)
@@ -249,9 +258,9 @@ var (
LibravatarService *libravatar.Libravatar LibravatarService *libravatar.Libravatar
) )
func Init() error { func Init(ctx context.Context) error {
var disableGravatar bool var disableGravatar bool
disableGravatarSetting, err := GetSettingNoCache(db.DefaultContext, KeyPictureDisableGravatar) disableGravatarSetting, err := GetSetting(ctx, KeyPictureDisableGravatar)
if IsErrSettingIsNotExist(err) { if IsErrSettingIsNotExist(err) {
disableGravatar = setting_module.GetDefaultDisableGravatar() disableGravatar = setting_module.GetDefaultDisableGravatar()
disableGravatarSetting = &Setting{SettingValue: strconv.FormatBool(disableGravatar)} disableGravatarSetting = &Setting{SettingValue: strconv.FormatBool(disableGravatar)}
@@ -262,7 +271,7 @@ func Init() error {
} }
var enableFederatedAvatar bool var enableFederatedAvatar bool
enableFederatedAvatarSetting, err := GetSettingNoCache(db.DefaultContext, KeyPictureEnableFederatedAvatar) enableFederatedAvatarSetting, err := GetSetting(ctx, KeyPictureEnableFederatedAvatar)
if IsErrSettingIsNotExist(err) { if IsErrSettingIsNotExist(err) {
enableFederatedAvatar = setting_module.GetDefaultEnableFederatedAvatar(disableGravatar) enableFederatedAvatar = setting_module.GetDefaultEnableFederatedAvatar(disableGravatar)
enableFederatedAvatarSetting = &Setting{SettingValue: strconv.FormatBool(enableFederatedAvatar)} enableFederatedAvatarSetting = &Setting{SettingValue: strconv.FormatBool(enableFederatedAvatar)}
@@ -275,13 +284,13 @@ func Init() error {
if setting_module.OfflineMode { if setting_module.OfflineMode {
disableGravatar = true disableGravatar = true
enableFederatedAvatar = false enableFederatedAvatar = false
if !GetSettingBool(db.DefaultContext, KeyPictureDisableGravatar) { if !GetSettingBool(ctx, KeyPictureDisableGravatar) {
if err := SetSettingNoVersion(db.DefaultContext, KeyPictureDisableGravatar, "true"); err != nil { if err := SetSettingNoVersion(ctx, KeyPictureDisableGravatar, "true"); err != nil {
return fmt.Errorf("Failed to set setting %q: %w", KeyPictureDisableGravatar, err) return fmt.Errorf("Failed to set setting %q: %w", KeyPictureDisableGravatar, err)
} }
} }
if GetSettingBool(db.DefaultContext, KeyPictureEnableFederatedAvatar) { if GetSettingBool(ctx, KeyPictureEnableFederatedAvatar) {
if err := SetSettingNoVersion(db.DefaultContext, KeyPictureEnableFederatedAvatar, "false"); err != nil { if err := SetSettingNoVersion(ctx, KeyPictureEnableFederatedAvatar, "false"); err != nil {
return fmt.Errorf("Failed to set setting %q: %w", KeyPictureEnableFederatedAvatar, err) return fmt.Errorf("Failed to set setting %q: %w", KeyPictureEnableFederatedAvatar, err)
} }
} }

View File

@@ -40,10 +40,10 @@ func TestSettings(t *testing.T) {
value, err := system.GetSetting(db.DefaultContext, keyName) value, err := system.GetSetting(db.DefaultContext, keyName)
assert.NoError(t, err) assert.NoError(t, err)
assert.EqualValues(t, updatedSetting.SettingValue, value) assert.EqualValues(t, updatedSetting.SettingValue, value.SettingValue)
// get all settings // get all settings
settings, err = system.GetAllSettings() settings, err = system.GetAllSettings(db.DefaultContext)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, settings, 3) assert.Len(t, settings, 3)
assert.EqualValues(t, updatedSetting.SettingValue, settings[strings.ToLower(updatedSetting.SettingKey)].SettingValue) assert.EqualValues(t, updatedSetting.SettingValue, settings[strings.ToLower(updatedSetting.SettingKey)].SettingValue)
@@ -51,7 +51,7 @@ func TestSettings(t *testing.T) {
// delete setting // delete setting
err = system.DeleteSetting(db.DefaultContext, &system.Setting{SettingKey: strings.ToLower(keyName)}) err = system.DeleteSetting(db.DefaultContext, &system.Setting{SettingKey: strings.ToLower(keyName)})
assert.NoError(t, err) assert.NoError(t, err)
settings, err = system.GetAllSettings() settings, err = system.GetAllSettings(db.DefaultContext)
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, settings, 2) assert.Len(t, settings, 2)
} }

View File

@@ -76,7 +76,7 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
setting.SSH.BuiltinServerUser = "builtinuser" setting.SSH.BuiltinServerUser = "builtinuser"
setting.SSH.Port = 3000 setting.SSH.Port = 3000
setting.SSH.Domain = "try.gitea.io" setting.SSH.Domain = "try.gitea.io"
setting.Database.UseSQLite3 = true setting.Database.Type = "sqlite3"
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master" setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
repoRootPath, err := os.MkdirTemp(os.TempDir(), "repos") repoRootPath, err := os.MkdirTemp(os.TempDir(), "repos")
if err != nil { if err != nil {
@@ -113,7 +113,7 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
if err = storage.Init(); err != nil { if err = storage.Init(); err != nil {
fatalTestError("storage.Init: %v\n", err) fatalTestError("storage.Init: %v\n", err)
} }
if err = system_model.Init(); err != nil { if err = system_model.Init(db.DefaultContext); err != nil {
fatalTestError("models.Init: %v\n", err) fatalTestError("models.Init: %v\n", err)
} }

View File

@@ -67,7 +67,7 @@ func (u *User) AvatarLinkWithSize(ctx context.Context, size int) string {
useLocalAvatar := false useLocalAvatar := false
autoGenerateAvatar := false autoGenerateAvatar := false
disableGravatar := system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar) disableGravatar := system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar)
switch { switch {
case u.UseCustomAvatar: case u.UseCustomAvatar:

View File

@@ -393,6 +393,11 @@ func (u *User) IsOrganization() bool {
return u.Type == UserTypeOrganization return u.Type == UserTypeOrganization
} }
// IsIndividual returns true if user is actually a individual user.
func (u *User) IsIndividual() bool {
return u.Type == UserTypeIndividual
}
// DisplayName returns full name if it's not empty, // DisplayName returns full name if it's not empty,
// returns username otherwise. // returns username otherwise.
func (u *User) DisplayName() string { func (u *User) DisplayName() string {

41
modules/actions/github.go Normal file
View File

@@ -0,0 +1,41 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package actions
import (
webhook_module "code.gitea.io/gitea/modules/webhook"
"github.com/nektos/act/pkg/jobparser"
)
const (
githubEventPullRequest = "pull_request"
githubEventPullRequestTarget = "pull_request_target"
githubEventPullRequestReviewComment = "pull_request_review_comment"
githubEventPullRequestReview = "pull_request_review"
githubEventRegistryPackage = "registry_package"
githubEventCreate = "create"
githubEventDelete = "delete"
githubEventFork = "fork"
githubEventPush = "push"
githubEventIssues = "issues"
githubEventIssueComment = "issue_comment"
githubEventRelease = "release"
githubEventPullRequestComment = "pull_request_comment"
)
func convertFromGithubEvent(evt *jobparser.Event) string {
switch evt.Name {
case githubEventPullRequest, githubEventPullRequestTarget, githubEventPullRequestReview,
githubEventPullRequestReviewComment:
return string(webhook_module.HookEventPullRequest)
case githubEventRegistryPackage:
return string(webhook_module.HookEventPackage)
case githubEventCreate, githubEventDelete, githubEventFork, githubEventPush,
githubEventIssues, githubEventIssueComment, githubEventRelease, githubEventPullRequestComment:
fallthrough
default:
return evt.Name
}
}

View File

@@ -72,9 +72,7 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
continue continue
} }
for _, evt := range events { for _, evt := range events {
if evt.Name != triggedEvent.Event() { log.Trace("detect workflow %q for event %#v matching %q", entry.Name(), evt, triggedEvent)
continue
}
if detectMatched(commit, triggedEvent, payload, evt) { if detectMatched(commit, triggedEvent, payload, evt) {
workflows[entry.Name()] = content workflows[entry.Name()] = content
} }
@@ -85,20 +83,58 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
} }
func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool { func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType, payload api.Payloader, evt *jobparser.Event) bool {
if convertFromGithubEvent(evt) != string(triggedEvent) {
return false
}
switch triggedEvent {
case webhook_module.HookEventCreate,
webhook_module.HookEventDelete,
webhook_module.HookEventFork,
webhook_module.HookEventIssueAssign,
webhook_module.HookEventIssueLabel,
webhook_module.HookEventIssueMilestone,
webhook_module.HookEventPullRequestAssign,
webhook_module.HookEventPullRequestLabel,
webhook_module.HookEventPullRequestMilestone,
webhook_module.HookEventPullRequestComment,
webhook_module.HookEventPullRequestReviewApproved,
webhook_module.HookEventPullRequestReviewRejected,
webhook_module.HookEventPullRequestReviewComment,
webhook_module.HookEventWiki,
webhook_module.HookEventRepository,
webhook_module.HookEventRelease,
webhook_module.HookEventPackage:
if len(evt.Acts) != 0 {
log.Warn("Ignore unsupported %s event arguments %q", triggedEvent, evt.Acts)
}
// no special filter parameters for these events, just return true if name matched
return true
case webhook_module.HookEventPush:
return matchPushEvent(commit, payload.(*api.PushPayload), evt)
case webhook_module.HookEventIssues:
return matchIssuesEvent(commit, payload.(*api.IssuePayload), evt)
case webhook_module.HookEventPullRequest, webhook_module.HookEventPullRequestSync:
return matchPullRequestEvent(commit, payload.(*api.PullRequestPayload), evt)
case webhook_module.HookEventIssueComment:
return matchIssueCommentEvent(commit, payload.(*api.IssueCommentPayload), evt)
default:
log.Warn("unsupported event %q", triggedEvent)
return false
}
}
func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobparser.Event) bool {
// with no special filter parameters
if len(evt.Acts) == 0 { if len(evt.Acts) == 0 {
return true return true
} }
switch triggedEvent {
case webhook_module.HookEventCreate:
fallthrough
case webhook_module.HookEventDelete:
fallthrough
case webhook_module.HookEventFork:
log.Warn("unsupported event %q", triggedEvent.Event())
return false
case webhook_module.HookEventPush:
pushPayload := payload.(*api.PushPayload)
matchTimes := 0 matchTimes := 0
// all acts conditions should be satisfied // all acts conditions should be satisfied
for cond, vals := range evt.Acts { for cond, vals := range evt.Acts {
@@ -131,30 +167,55 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
} }
} }
default: default:
log.Warn("unsupported condition %q", cond) log.Warn("push event unsupported condition %q", cond)
} }
} }
return matchTimes == len(evt.Acts) return matchTimes == len(evt.Acts)
}
func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *jobparser.Event) bool {
// with no special filter parameters
if len(evt.Acts) == 0 {
return true
}
case webhook_module.HookEventIssues:
fallthrough
case webhook_module.HookEventIssueAssign:
fallthrough
case webhook_module.HookEventIssueLabel:
fallthrough
case webhook_module.HookEventIssueMilestone:
fallthrough
case webhook_module.HookEventIssueComment:
fallthrough
case webhook_module.HookEventPullRequest:
prPayload := payload.(*api.PullRequestPayload)
matchTimes := 0 matchTimes := 0
// all acts conditions should be satisfied // all acts conditions should be satisfied
for cond, vals := range evt.Acts { for cond, vals := range evt.Acts {
switch cond { switch cond {
case "types": case "types":
for _, val := range vals { for _, val := range vals {
if glob.MustCompile(val, '/').Match(string(prPayload.Action)) { if glob.MustCompile(val, '/').Match(string(issuePayload.Action)) {
matchTimes++
break
}
}
default:
log.Warn("issue event unsupported condition %q", cond)
}
}
return matchTimes == len(evt.Acts)
}
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
// with no special filter parameters
if len(evt.Acts) == 0 {
// defaultly, only pull request opened and synchronized will trigger workflow
return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened
}
matchTimes := 0
// all acts conditions should be satisfied
for cond, vals := range evt.Acts {
switch cond {
case "types":
action := prPayload.Action
if prPayload.Action == api.HookIssueSynchronized {
action = "synchronize"
}
log.Trace("matching pull_request %s with %v", action, vals)
for _, val := range vals {
if glob.MustCompile(val, '/').Match(string(action)) {
matchTimes++ matchTimes++
break break
} }
@@ -187,36 +248,32 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
} }
} }
default: default:
log.Warn("unsupported condition %q", cond) log.Warn("pull request event unsupported condition %q", cond)
} }
} }
return matchTimes == len(evt.Acts) return matchTimes == len(evt.Acts)
case webhook_module.HookEventPullRequestAssign: }
fallthrough
case webhook_module.HookEventPullRequestLabel: func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {
fallthrough // with no special filter parameters
case webhook_module.HookEventPullRequestMilestone: if len(evt.Acts) == 0 {
fallthrough return true
case webhook_module.HookEventPullRequestComment: }
fallthrough
case webhook_module.HookEventPullRequestReviewApproved: matchTimes := 0
fallthrough // all acts conditions should be satisfied
case webhook_module.HookEventPullRequestReviewRejected: for cond, vals := range evt.Acts {
fallthrough switch cond {
case webhook_module.HookEventPullRequestReviewComment: case "types":
fallthrough for _, val := range vals {
case webhook_module.HookEventPullRequestSync: if glob.MustCompile(val, '/').Match(string(issueCommentPayload.Action)) {
fallthrough matchTimes++
case webhook_module.HookEventWiki: break
fallthrough }
case webhook_module.HookEventRepository: }
fallthrough
case webhook_module.HookEventRelease:
fallthrough
case webhook_module.HookEventPackage:
fallthrough
default: default:
log.Warn("unsupported event %q", triggedEvent.Event()) log.Warn("issue comment unsupported condition %q", cond)
} }
return false }
return matchTimes == len(evt.Acts)
} }

View File

@@ -41,9 +41,8 @@ var RecommendedHashAlgorithms = []string{
"pbkdf2_hi", "pbkdf2_hi",
} }
// SetDefaultPasswordHashAlgorithm will take a provided algorithmName and dealias it to // hashAlgorithmToSpec converts an algorithm name or a specification to a full algorithm specification
// a complete algorithm specification. func hashAlgorithmToSpec(algorithmName string) string {
func SetDefaultPasswordHashAlgorithm(algorithmName string) (string, *PasswordHashAlgorithm) {
if algorithmName == "" { if algorithmName == "" {
algorithmName = DefaultHashAlgorithmName algorithmName = DefaultHashAlgorithmName
} }
@@ -52,10 +51,26 @@ func SetDefaultPasswordHashAlgorithm(algorithmName string) (string, *PasswordHas
algorithmName = alias algorithmName = alias
alias, has = aliasAlgorithmNames[algorithmName] alias, has = aliasAlgorithmNames[algorithmName]
} }
return algorithmName
// algorithmName should now be a full algorithm specification }
// e.g. pbkdf2$50000$50 rather than pbdkf2
DefaultHashAlgorithm = Parse(algorithmName) // SetDefaultPasswordHashAlgorithm will take a provided algorithmName and de-alias it to
// a complete algorithm specification.
return algorithmName, DefaultHashAlgorithm func SetDefaultPasswordHashAlgorithm(algorithmName string) (string, *PasswordHashAlgorithm) {
algoSpec := hashAlgorithmToSpec(algorithmName)
// now we get a full specification, e.g. pbkdf2$50000$50 rather than pbdkf2
DefaultHashAlgorithm = Parse(algoSpec)
return algoSpec, DefaultHashAlgorithm
}
// ConfigHashAlgorithm will try to find a "recommended algorithm name" defined by RecommendedHashAlgorithms for config
// This function is not fast and is only used for the installation page
func ConfigHashAlgorithm(algorithm string) string {
algorithm = hashAlgorithmToSpec(algorithm)
for _, recommAlgo := range RecommendedHashAlgorithms {
if algorithm == hashAlgorithmToSpec(recommAlgo) {
return recommAlgo
}
}
return algorithm
} }

View File

@@ -244,7 +244,7 @@ func APIContexter() func(http.Handler) http.Handler {
} }
} }
httpcache.AddCacheControlToHeader(ctx.Resp.Header(), 0, "no-transform") httpcache.SetCacheControlInHeader(ctx.Resp.Header(), 0, "no-transform")
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions) ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
ctx.Data["Context"] = &ctx ctx.Data["Context"] = &ctx

View File

@@ -388,7 +388,7 @@ func (ctx *Context) SetServeHeaders(opts *ServeHeaderOptions) {
if duration == 0 { if duration == 0 {
duration = 5 * time.Minute duration = 5 * time.Minute
} }
httpcache.AddCacheControlToHeader(header, duration) httpcache.SetCacheControlInHeader(header, duration)
if !opts.LastModified.IsZero() { if !opts.LastModified.IsZero() {
header.Set("Last-Modified", opts.LastModified.UTC().Format(http.TimeFormat)) header.Set("Last-Modified", opts.LastModified.UTC().Format(http.TimeFormat))
@@ -753,7 +753,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler {
} }
} }
httpcache.AddCacheControlToHeader(ctx.Resp.Header(), 0, "no-transform") httpcache.SetCacheControlInHeader(ctx.Resp.Header(), 0, "no-transform")
ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions) ctx.Resp.Header().Set(`X-Frame-Options`, setting.CORSConfig.XFrameOptions)
ctx.Data["CsrfToken"] = ctx.csrf.GetToken() ctx.Data["CsrfToken"] = ctx.csrf.GetToken()

View File

@@ -11,7 +11,6 @@ import (
"code.gitea.io/gitea/models/perm" "code.gitea.io/gitea/models/perm"
"code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/structs"
) )
@@ -31,29 +30,34 @@ type Organization struct {
} }
func (org *Organization) CanWriteUnit(ctx *Context, unitType unit.Type) bool { func (org *Organization) CanWriteUnit(ctx *Context, unitType unit.Type) bool {
if ctx.Doer == nil { return org.Organization.UnitPermission(ctx, ctx.Doer, unitType) >= perm.AccessModeWrite
return false
}
return org.UnitPermission(ctx, ctx.Doer.ID, unitType) >= perm.AccessModeWrite
} }
func (org *Organization) UnitPermission(ctx *Context, doerID int64, unitType unit.Type) perm.AccessMode { func (org *Organization) CanReadUnit(ctx *Context, unitType unit.Type) bool {
if doerID > 0 { return org.Organization.UnitPermission(ctx, ctx.Doer, unitType) >= perm.AccessModeRead
teams, err := organization.GetUserOrgTeams(ctx, org.Organization.ID, doerID) }
func GetOrganizationByParams(ctx *Context) {
orgName := ctx.Params(":org")
var err error
ctx.Org.Organization, err = organization.GetOrgByName(ctx, orgName)
if err != nil { if err != nil {
log.Error("GetUserOrgTeams: %v", err) if organization.IsErrOrgNotExist(err) {
return perm.AccessModeNone redirectUserID, err := user_model.LookupUserRedirect(orgName)
if err == nil {
RedirectToUser(ctx, orgName, redirectUserID)
} else if user_model.IsErrUserRedirectNotExist(err) {
ctx.NotFound("GetUserByName", err)
} else {
ctx.ServerError("LookupUserRedirect", err)
} }
if len(teams) > 0 { } else {
return teams.UnitMaxAccess(unitType) ctx.ServerError("GetUserByName", err)
} }
return
} }
if org.Organization.Visibility == structs.VisibleTypePublic {
return perm.AccessModeRead
}
return perm.AccessModeNone
} }
// HandleOrgAssignment handles organization assignment // HandleOrgAssignment handles organization assignment
@@ -77,25 +81,26 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
requireTeamAdmin = args[3] requireTeamAdmin = args[3]
} }
orgName := ctx.Params(":org")
var err error var err error
ctx.Org.Organization, err = organization.GetOrgByName(ctx, orgName)
if err != nil { if ctx.ContextUser == nil {
if organization.IsErrOrgNotExist(err) { // if Organization is not defined, get it from params
redirectUserID, err := user_model.LookupUserRedirect(orgName) if ctx.Org.Organization == nil {
if err == nil { GetOrganizationByParams(ctx)
RedirectToUser(ctx, orgName, redirectUserID) if ctx.Written() {
} else if user_model.IsErrUserRedirectNotExist(err) {
ctx.NotFound("GetUserByName", err)
} else {
ctx.ServerError("LookupUserRedirect", err)
}
} else {
ctx.ServerError("GetUserByName", err)
}
return return
} }
}
} else if ctx.ContextUser.IsOrganization() {
if ctx.Org == nil {
ctx.Org = &Organization{}
}
ctx.Org.Organization = (*organization.Organization)(ctx.ContextUser)
} else {
// ContextUser is an individual User
return
}
org := ctx.Org.Organization org := ctx.Org.Organization
// Handle Visibility // Handle Visibility
@@ -156,6 +161,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
} }
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember
ctx.Data["IsProjectEnabled"] = true
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
ctx.Data["IsPublicMember"] = func(uid int64) bool { ctx.Data["IsPublicMember"] = func(uid int64) bool {
@@ -231,6 +237,10 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
return return
} }
} }
ctx.Data["CanReadProjects"] = ctx.Org.CanReadUnit(ctx, unit.TypeProjects)
ctx.Data["CanReadPackages"] = ctx.Org.CanReadUnit(ctx, unit.TypePackages)
ctx.Data["CanReadCode"] = ctx.Org.CanReadUnit(ctx, unit.TypeCode)
} }
// OrgAssignment returns a middleware to handle organization assignment // OrgAssignment returns a middleware to handle organization assignment

View File

@@ -18,10 +18,11 @@ type Pagination struct {
urlParams []string urlParams []string
} }
// NewPagination creates a new instance of the Pagination struct // NewPagination creates a new instance of the Pagination struct.
func NewPagination(total, page, issueNum, numPages int) *Pagination { // "pagingNum" is "page size" or "limit", "current" is "page"
func NewPagination(total, pagingNum, current, numPages int) *Pagination {
p := &Pagination{} p := &Pagination{}
p.Paginater = paginator.New(total, page, issueNum, numPages) p.Paginater = paginator.New(total, pagingNum, current, numPages)
return p return p
} }

View File

@@ -11,6 +11,7 @@ import (
"strings" "strings"
"testing" "testing"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -229,7 +230,10 @@ John Doe john@doe.com This,note,had,a,lot,of,commas,to,test,delimiters`,
} }
for n, c := range cases { for n, c := range cases {
delimiter := determineDelimiter(&markup.RenderContext{RelativePath: c.filename}, []byte(decodeSlashes(t, c.csv))) delimiter := determineDelimiter(&markup.RenderContext{
Ctx: git.DefaultContext,
RelativePath: c.filename,
}, []byte(decodeSlashes(t, c.csv)))
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter) assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
} }
} }

View File

@@ -155,7 +155,7 @@ func checkDBConsistency(ctx context.Context, logger log.Logger, autofix bool) er
// TODO: function to recalc all counters // TODO: function to recalc all counters
if setting.Database.UsePostgreSQL { if setting.Database.Type.IsPostgreSQL() {
consistencyChecks = append(consistencyChecks, consistencyCheck{ consistencyChecks = append(consistencyChecks, consistencyCheck{
Name: "Sequence values", Name: "Sequence values",
Counter: db.CountBadSequences, Counter: db.CountBadSequences,

View File

@@ -179,7 +179,7 @@ func (c *Command) AddDashesAndList(list ...string) *Command {
} }
// ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs // ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs
// In most cases, it shouldn't be used. Use AddXxx function instead // In most cases, it shouldn't be used. Use NewCommand().AddXxx() function instead
func ToTrustedCmdArgs(args []string) TrustedCmdArgs { func ToTrustedCmdArgs(args []string) TrustedCmdArgs {
ret := make(TrustedCmdArgs, len(args)) ret := make(TrustedCmdArgs, len(args))
for i, arg := range args { for i, arg := range args {

View File

@@ -201,6 +201,23 @@ func InitFull(ctx context.Context) (err error) {
return syncGitConfig() return syncGitConfig()
} }
func enableReflogs() error {
if err := configSet("core.logAllRefUpdates", "true"); err != nil {
return err
}
err := configSet("gc.reflogExpire", fmt.Sprintf("%d", setting.Git.Reflog.Expiration))
return err
}
func disableReflogs() error {
if err := configUnsetAll("core.logAllRefUpdates", "true"); err != nil {
return err
} else if err := configUnsetAll("gc.reflogExpire", ""); err != nil {
return err
}
return nil
}
// syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem) // syncGitConfig only modifies gitconfig, won't change global variables (otherwise there will be data-race problem)
func syncGitConfig() (err error) { func syncGitConfig() (err error) {
if err = os.MkdirAll(HomeDir(), os.ModePerm); err != nil { if err = os.MkdirAll(HomeDir(), os.ModePerm); err != nil {
@@ -224,6 +241,16 @@ func syncGitConfig() (err error) {
return err return err
} }
if setting.Git.Reflog.Enabled {
if err := enableReflogs(); err != nil {
return err
}
} else {
if err := disableReflogs(); err != nil {
return err
}
}
if CheckGitVersionAtLeast("2.10") == nil { if CheckGitVersionAtLeast("2.10") == nil {
if err := configSet("receive.advertisePushOptions", "true"); err != nil { if err := configSet("receive.advertisePushOptions", "true"); err != nil {
return err return err
@@ -312,7 +339,7 @@ func CheckGitVersionAtLeast(atLeast string) error {
} }
func configSet(key, value string) error { func configSet(key, value string) error {
stdout, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil) stdout, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
if err != nil && !err.IsExitCode(1) { if err != nil && !err.IsExitCode(1) {
return fmt.Errorf("failed to get git config %s, err: %w", key, err) return fmt.Errorf("failed to get git config %s, err: %w", key, err)
} }
@@ -331,7 +358,7 @@ func configSet(key, value string) error {
} }
func configSetNonExist(key, value string) error { func configSetNonExist(key, value string) error {
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil) _, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
if err == nil { if err == nil {
// already exist // already exist
return nil return nil
@@ -349,7 +376,7 @@ func configSetNonExist(key, value string) error {
} }
func configAddNonExist(key, value string) error { func configAddNonExist(key, value string) error {
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil) _, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)
if err == nil { if err == nil {
// already exist // already exist
return nil return nil
@@ -366,7 +393,7 @@ func configAddNonExist(key, value string) error {
} }
func configUnsetAll(key, value string) error { func configUnsetAll(key, value string) error {
_, _, err := NewCommand(DefaultContext, "config", "--get").AddDynamicArguments(key).RunStdString(nil) _, _, err := NewCommand(DefaultContext, "config", "--global", "--get").AddDynamicArguments(key).RunStdString(nil)
if err == nil { if err == nil {
// exist, need to remove // exist, need to remove
_, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil) _, _, err = NewCommand(DefaultContext, "config", "--global", "--unset-all").AddDynamicArguments(key, regexp.QuoteMeta(value)).RunStdString(nil)

View File

@@ -42,7 +42,10 @@ func RevListObjects(ctx context.Context, revListWriter *io.PipeWriter, wg *sync.
defer revListWriter.Close() defer revListWriter.Close()
stderr := new(bytes.Buffer) stderr := new(bytes.Buffer)
var errbuf strings.Builder var errbuf strings.Builder
cmd := git.NewCommand(ctx, "rev-list", "--objects").AddDynamicArguments(headSHA).AddArguments("--not").AddDynamicArguments(baseSHA) cmd := git.NewCommand(ctx, "rev-list", "--objects").AddDynamicArguments(headSHA)
if baseSHA != "" {
cmd = cmd.AddArguments("--not").AddDynamicArguments(baseSHA)
}
if err := cmd.Run(&git.RunOpts{ if err := cmd.Run(&git.RunOpts{
Dir: tmpBasePath, Dir: tmpBasePath,
Stdout: revListWriter, Stdout: revListWriter,

View File

@@ -7,7 +7,6 @@
package git package git
import ( import (
"fmt"
"strings" "strings"
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
@@ -67,38 +66,6 @@ func (repo *Repository) IsCommitExist(name string) bool {
return err == nil return err == nil
} }
func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {
if t.PGPSignature == "" {
return nil
}
var w strings.Builder
var err error
if _, err = fmt.Fprintf(&w,
"object %s\ntype %s\ntag %s\ntagger ",
t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil {
return nil
}
if err = t.Tagger.Encode(&w); err != nil {
return nil
}
if _, err = fmt.Fprintf(&w, "\n\n"); err != nil {
return nil
}
if _, err = fmt.Fprintf(&w, t.Message); err != nil {
return nil
}
return &CommitGPGSignature{
Signature: t.PGPSignature,
Payload: strings.TrimSpace(w.String()) + "\n",
}
}
func (repo *Repository) getCommit(id SHA1) (*Commit, error) { func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
var tagObject *object.Tag var tagObject *object.Tag
@@ -122,12 +89,6 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
commit := convertCommit(gogitCommit) commit := convertCommit(gogitCommit)
commit.repo = repo commit.repo = repo
if tagObject != nil {
commit.CommitMessage = strings.TrimSpace(tagObject.Message)
commit.Author = &tagObject.Tagger
commit.Signature = convertPGPSignatureForTag(tagObject)
}
tree, err := gogitCommit.Tree() tree, err := gogitCommit.Tree()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -107,10 +107,6 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id SHA1) (*Co
return nil, err return nil, err
} }
commit.CommitMessage = strings.TrimSpace(tag.Message)
commit.Author = tag.Tagger
commit.Signature = tag.Signature
return commit, nil return commit, nil
case "commit": case "commit":
commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size)) commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))

View File

@@ -43,12 +43,13 @@ func TestGetTagCommitWithSignature(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
defer bareRepo1.Close() defer bareRepo1.Close()
commit, err := bareRepo1.GetCommit("3ad28a9149a2864384548f3d17ed7f38014c9e8a") // both the tag and the commit are signed here, this validates only the commit signature
commit, err := bareRepo1.GetCommit("28b55526e7100924d864dd89e35c1ea62e7a5a32")
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, commit) assert.NotNil(t, commit)
assert.NotNil(t, commit.Signature) assert.NotNil(t, commit.Signature)
// test that signature is not in message // test that signature is not in message
assert.Equal(t, "tag", commit.CommitMessage) assert.Equal(t, "signed-commit\n", commit.CommitMessage)
} }
func TestGetCommitWithBadCommitID(t *testing.T) { func TestGetCommitWithBadCommitID(t *testing.T) {

View File

@@ -277,11 +277,18 @@ func (repo *Repository) GetPatch(base, head string, w io.Writer) error {
// GetFilesChangedBetween returns a list of all files that have been changed between the given commits // GetFilesChangedBetween returns a list of all files that have been changed between the given commits
func (repo *Repository) GetFilesChangedBetween(base, head string) ([]string, error) { func (repo *Repository) GetFilesChangedBetween(base, head string) ([]string, error) {
stdout, _, err := NewCommand(repo.Ctx, "diff", "--name-only").AddDynamicArguments(base + ".." + head).RunStdString(&RunOpts{Dir: repo.Path}) stdout, _, err := NewCommand(repo.Ctx, "diff", "--name-only", "-z").AddDynamicArguments(base + ".." + head).RunStdString(&RunOpts{Dir: repo.Path})
if err != nil { if err != nil {
return nil, err return nil, err
} }
return strings.Split(stdout, "\n"), err split := strings.Split(stdout, "\000")
// Because Git will always emit filenames with a terminal NUL ignore the last entry in the split - which will always be empty.
if len(split) > 0 {
split = split[:len(split)-1]
}
return split, err
} }
// GetDiffFromMergeBase generates and return patch data from merge base to head // GetDiffFromMergeBase generates and return patch data from merge base to head

View File

@@ -19,13 +19,14 @@ func TestRepository_GetRefs(t *testing.T) {
refs, err := bareRepo1.GetRefs() refs, err := bareRepo1.GetRefs()
assert.NoError(t, err) assert.NoError(t, err)
assert.Len(t, refs, 5) assert.Len(t, refs, 6)
expectedRefs := []string{ expectedRefs := []string{
BranchPrefix + "branch1", BranchPrefix + "branch1",
BranchPrefix + "branch2", BranchPrefix + "branch2",
BranchPrefix + "master", BranchPrefix + "master",
TagPrefix + "test", TagPrefix + "test",
TagPrefix + "signed-tag",
NotesRef, NotesRef,
} }
@@ -43,9 +44,12 @@ func TestRepository_GetRefsFiltered(t *testing.T) {
refs, err := bareRepo1.GetRefsFiltered(TagPrefix) refs, err := bareRepo1.GetRefsFiltered(TagPrefix)
assert.NoError(t, err) assert.NoError(t, err)
if assert.Len(t, refs, 1) { if assert.Len(t, refs, 2) {
assert.Equal(t, TagPrefix+"test", refs[0].Name) assert.Equal(t, TagPrefix+"signed-tag", refs[0].Name)
assert.Equal(t, "tag", refs[0].Type) assert.Equal(t, "tag", refs[0].Type)
assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", refs[0].Object.String()) assert.Equal(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", refs[0].Object.String())
assert.Equal(t, TagPrefix+"test", refs[1].Name)
assert.Equal(t, "tag", refs[1].Type)
assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", refs[1].Object.String())
} }
} }

View File

@@ -24,9 +24,9 @@ func TestRepository_GetCodeActivityStats(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
assert.NotNil(t, code) assert.NotNil(t, code)
assert.EqualValues(t, 9, code.CommitCount) assert.EqualValues(t, 10, code.CommitCount)
assert.EqualValues(t, 3, code.AuthorCount) assert.EqualValues(t, 3, code.AuthorCount)
assert.EqualValues(t, 9, code.CommitCountInAllBranches) assert.EqualValues(t, 10, code.CommitCountInAllBranches)
assert.EqualValues(t, 10, code.Additions) assert.EqualValues(t, 10, code.Additions)
assert.EqualValues(t, 1, code.Deletions) assert.EqualValues(t, 1, code.Deletions)
assert.Len(t, code.Authors, 3) assert.Len(t, code.Authors, 3)

View File

@@ -25,11 +25,14 @@ func TestRepository_GetTags(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
return return
} }
assert.Len(t, tags, 1) assert.Len(t, tags, 2)
assert.Equal(t, len(tags), total) assert.Equal(t, len(tags), total)
assert.EqualValues(t, "test", tags[0].Name) assert.EqualValues(t, "signed-tag", tags[0].Name)
assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[0].ID.String()) assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
assert.EqualValues(t, "tag", tags[0].Type) assert.EqualValues(t, "tag", tags[0].Type)
assert.EqualValues(t, "test", tags[1].Name)
assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String())
assert.EqualValues(t, "tag", tags[1].Type)
} }
func TestRepository_GetTag(t *testing.T) { func TestRepository_GetTag(t *testing.T) {

View File

@@ -14,10 +14,10 @@ func TestGetLatestCommitTime(t *testing.T) {
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare") bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
lct, err := GetLatestCommitTime(DefaultContext, bareRepo1Path) lct, err := GetLatestCommitTime(DefaultContext, bareRepo1Path)
assert.NoError(t, err) assert.NoError(t, err)
// Time is Sun Jul 21 22:43:13 2019 +0200 // Time is Sun Nov 13 16:40:14 2022 +0100
// which is the time of commit // which is the time of commit
// feaf4ba6bc635fec442f46ddd4512416ec43c2c2 (refs/heads/master) // ce064814f4a0d337b333e646ece456cd39fab612 (refs/heads/master)
assert.EqualValues(t, 1563741793, lct.Unix()) assert.EqualValues(t, 1668354014, lct.Unix())
} }
func TestRepoIsEmpty(t *testing.T) { func TestRepoIsEmpty(t *testing.T) {

Binary file not shown.

View File

@@ -1 +1,2 @@
37991dec2c8e592043f47155ce4808d4580f9123 feaf4ba6bc635fec442f46ddd4512416ec43c2c2 silverwind <me@silverwind.io> 1563741799 +0200 push 37991dec2c8e592043f47155ce4808d4580f9123 feaf4ba6bc635fec442f46ddd4512416ec43c2c2 silverwind <me@silverwind.io> 1563741799 +0200 push
feaf4ba6bc635fec442f46ddd4512416ec43c2c2 ce064814f4a0d337b333e646ece456cd39fab612 silverwind <me@silverwind.io> 1668354026 +0100 push

View File

@@ -1 +1,2 @@
37991dec2c8e592043f47155ce4808d4580f9123 feaf4ba6bc635fec442f46ddd4512416ec43c2c2 silverwind <me@silverwind.io> 1563741799 +0200 push 37991dec2c8e592043f47155ce4808d4580f9123 feaf4ba6bc635fec442f46ddd4512416ec43c2c2 silverwind <me@silverwind.io> 1563741799 +0200 push
feaf4ba6bc635fec442f46ddd4512416ec43c2c2 ce064814f4a0d337b333e646ece456cd39fab612 silverwind <me@silverwind.io> 1668354026 +0100 push

View File

@@ -1 +1 @@
feaf4ba6bc635fec442f46ddd4512416ec43c2c2 ce064814f4a0d337b333e646ece456cd39fab612

View File

@@ -0,0 +1 @@
36f97d9a96457e2bab511db30fe2db03893ebc64

View File

@@ -15,8 +15,8 @@ import (
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
) )
// AddCacheControlToHeader adds suitable cache-control headers to response // SetCacheControlInHeader sets suitable cache-control headers in the response
func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDirectives ...string) { func SetCacheControlInHeader(h http.Header, maxAge time.Duration, additionalDirectives ...string) {
directives := make([]string, 0, 2+len(additionalDirectives)) directives := make([]string, 0, 2+len(additionalDirectives))
// "max-age=0 + must-revalidate" (aka "no-cache") is preferred instead of "no-store" // "max-age=0 + must-revalidate" (aka "no-cache") is preferred instead of "no-store"
@@ -31,7 +31,7 @@ func AddCacheControlToHeader(h http.Header, maxAge time.Duration, additionalDire
directives = append(directives, "max-age=0", "private", "must-revalidate") directives = append(directives, "max-age=0", "private", "must-revalidate")
// to remind users they are using non-prod setting. // to remind users they are using non-prod setting.
h.Add("X-Gitea-Debug", "RUN_MODE="+setting.RunMode) h.Set("X-Gitea-Debug", "RUN_MODE="+setting.RunMode)
} }
h.Set("Cache-Control", strings.Join(append(directives, additionalDirectives...), ", ")) h.Set("Cache-Control", strings.Join(append(directives, additionalDirectives...), ", "))
@@ -50,7 +50,7 @@ func HandleTimeCache(req *http.Request, w http.ResponseWriter, fi os.FileInfo) (
// HandleGenericTimeCache handles time-based caching for a HTTP request // HandleGenericTimeCache handles time-based caching for a HTTP request
func HandleGenericTimeCache(req *http.Request, w http.ResponseWriter, lastModified time.Time) (handled bool) { func HandleGenericTimeCache(req *http.Request, w http.ResponseWriter, lastModified time.Time) (handled bool) {
AddCacheControlToHeader(w.Header(), setting.StaticCacheTime) SetCacheControlInHeader(w.Header(), setting.StaticCacheTime)
ifModifiedSince := req.Header.Get("If-Modified-Since") ifModifiedSince := req.Header.Get("If-Modified-Since")
if ifModifiedSince != "" { if ifModifiedSince != "" {
@@ -81,7 +81,7 @@ func HandleGenericETagCache(req *http.Request, w http.ResponseWriter, etag strin
return true return true
} }
} }
AddCacheControlToHeader(w.Header(), setting.StaticCacheTime) SetCacheControlInHeader(w.Header(), setting.StaticCacheTime)
return false return false
} }
@@ -125,6 +125,6 @@ func HandleGenericETagTimeCache(req *http.Request, w http.ResponseWriter, etag s
} }
} }
} }
AddCacheControlToHeader(w.Header(), setting.StaticCacheTime) SetCacheControlInHeader(w.Header(), setting.StaticCacheTime)
return false return false
} }

Some files were not shown because too many files have changed in this diff Show More