]> source.dussan.org Git - gitea.git/log
gitea.git
20 months agoFix .golangci.yml (#22868)
zeripath [Sat, 11 Feb 2023 21:44:53 +0000 (21:44 +0000)]
Fix .golangci.yml (#22868)

When we updated the .golangci.yml for 1.20 we should have used a string
as 1.20 is not a valid number.

In doing so we need to restore the nolint markings within the pq driver.

Signed-off-by: Andrew Thornton <art27@cantab.net>
20 months agoFix migration issue. (#22867)
Nathaniel Sabanski [Sat, 11 Feb 2023 21:28:41 +0000 (13:28 -0800)]
Fix migration issue. (#22867)

See:
https://github.com/go-gitea/gitea/pull/22112#issuecomment-1426872992

20 months agoAdd `/$count` endpoints for NuGet v2 (#22855)
KN4CK3R [Sat, 11 Feb 2023 11:30:44 +0000 (12:30 +0100)]
Add `/$count` endpoints for NuGet v2 (#22855)

Fixes #22838

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoPreview images for Issue cards in Project Board view (#22112)
Nathaniel Sabanski [Sat, 11 Feb 2023 08:12:41 +0000 (00:12 -0800)]
Preview images for Issue cards in Project Board view (#22112)

Original Issue: https://github.com/go-gitea/gitea/issues/22102

This addition would be a big benefit for design and art teams using the
issue tracking.

The preview will be the latest "image type" attachments on an issue-
simple, and allows for automatic updates of the cover image as issue
progress is made!

This would make Gitea competitive with Trello... wouldn't it be amazing
to say goodbye to Atlassian products? Ha.

First image is the most recent, the SQL will fetch up to 5 latest images
(URL string).

All images supported by browsers plus upcoming formats: *.avif *.bmp
*.gif *.jpg *.jpeg *.jxl *.png *.svg *.webp

The CSS will try to center-align images until it cannot, then it will
left align with overflow hidden. Single images get to be slightly
larger!

Tested so far on: Chrome, Firefox, Android Chrome, Android Firefox.

Current revision with light and dark themes:

![image](https://user-images.githubusercontent.com/24665/207066878-58e6bf73-0c93-4caa-8d40-38f4432b3578.png)

![image](https://user-images.githubusercontent.com/24665/207066555-293f65c3-e706-4888-8516-de8ec632d638.png)

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
20 months agoFix improper HTMLURL usages in Go code (#22839)
wxiaoguang [Sat, 11 Feb 2023 06:34:11 +0000 (14:34 +0800)]
Fix improper HTMLURL usages in Go code (#22839)

In Go code, HTMLURL should be only used for external systems, like
API/webhook/mail/notification, etc.

If a URL is used by `Redirect` or rendered in a template, it should be a
relative URL (aka `Link()` in Gitea)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoUse proxy for pull mirror (#22771)
Gusted [Sat, 11 Feb 2023 00:39:50 +0000 (01:39 +0100)]
Use proxy for pull mirror (#22771)

- Use the proxy (if one is specified) for pull mirrors syncs.
- Pulled the code from
https://github.com/go-gitea/gitea/blob/c2774d9e80d9a436d9c2044960369c4db227e3a0/modules/git/repo.go#L164-L170

Downstream issue: https://codeberg.org/forgejo/forgejo/issues/302

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
20 months agoMake issue title edit buttons focusable and fix incorrect ajax requests (#22807)
wxiaoguang [Thu, 9 Feb 2023 17:11:16 +0000 (01:11 +0800)]
Make issue title edit buttons focusable and fix incorrect ajax requests (#22807)

Replace #19922 , which is stale since my last review:
https://github.com/go-gitea/gitea/pull/19922#pullrequestreview-1003546506
and https://github.com/go-gitea/gitea/pull/19922#issuecomment-1153181546

Close #19769

Changes:
1. Use `<button>` instead of `<div>` for buttons
2. Prevent default event handler in `initGlobalButtonClickOnEnter`
3. Fix the incorrect call to `pullrequest_targetbranch_change`
4. Add a slight margin-left to the input element to make UI look better

The logic in repo-issue.js is not ideal, but this PR isn't going to
touch the logic.

This is also an example for future developers to understand how to make
buttons work properly.

### Before

![image](https://user-images.githubusercontent.com/2114189/217262515-ec0462f7-7051-46a5-bfa2-2f6c6a807b7d.png)

### After

* Add a slight margin-left.
* The `Cancel` button is focused.

![image](https://user-images.githubusercontent.com/2114189/217264891-934c9c8d-d190-4866-98b5-666cea57e28d.png)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoFix update by rebase being wrongly disabled by protected base branch (#22825)
Brecht Van Lommel [Thu, 9 Feb 2023 17:08:42 +0000 (18:08 +0100)]
Fix update by rebase being wrongly disabled by protected base branch (#22825)

The branch this is force pushing to is the head branch in the head repo,
so it should be checking if that is protected, not the base.

20 months agoFix inconsistent Filter Project name in issue list (#22827)
Brecht Van Lommel [Thu, 9 Feb 2023 16:39:31 +0000 (17:39 +0100)]
Fix inconsistent Filter Project name in issue list (#22827)

Use Project instead of Filter Project like the other filter menus.

20 months agoFix more HTMLURL in templates (#22831)
wxiaoguang [Thu, 9 Feb 2023 16:31:30 +0000 (00:31 +0800)]
Fix more HTMLURL in templates (#22831)

I haven't tested `runs_list.tmpl` but I think it could be right.

After this PR, besides the `<meta .. HTMLURL>` in html head, the only
explicit HTMLURL usage is in `pull_merge_instruction.tmpl`, which
doesn't affect users too much and it's difficult to fix at the moment.

There are still many usages of `AppUrl` in the templates (eg: the
package help manual), they are similar problems as the HTMLURL in
pull_merge_instruction, and they might be fixed together in the future.

Diff without space:
https://github.com/go-gitea/gitea/pull/22831/files?diff=unified&w=1

20 months agoFix unmatched div in project filter (#22832)
John Olheiser [Thu, 9 Feb 2023 16:15:07 +0000 (10:15 -0600)]
Fix unmatched div in project filter (#22832)

(Note that the below screenshots aren't the same repo, the former is try
and the latter is local)

Before

![div-before](https://user-images.githubusercontent.com/42128690/217723899-a15da77f-a196-4b23-a157-e7f1e1979610.png)

After

![div-after](https://user-images.githubusercontent.com/42128690/217723878-e54235bc-a7d7-425e-bd0d-47d1814f18ba.png)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoImprove AppUrl/ROOT_URL checking (#22836)
wxiaoguang [Thu, 9 Feb 2023 16:14:45 +0000 (00:14 +0800)]
Improve AppUrl/ROOT_URL checking (#22836)

After some PRs:
* #21986
* #22795
* #22808
* #22831
* #22839

Users won't be affected by the ROOT_URL problem in most cases. Close
#19345

This PR improves AppUrl/ROOT_URL checking, only check it on the admin
page, and the message is also updated.

Feel free to suggest about more English-native messages.

![image](https://user-images.githubusercontent.com/2114189/217811809-7d44ddb7-2c4a-46d0-a5db-8ae6ee65f8c3.png)

20 months agoFix isAllowed of escapeStreamer (#22814)
Jason Song [Thu, 9 Feb 2023 12:51:36 +0000 (20:51 +0800)]
Fix isAllowed of escapeStreamer (#22814)

The use of `sort.Search` is wrong: The slice should be sorted, and
`return >= 0` doen't mean it exists, see the
[manual](https://pkg.go.dev/sort#Search).

Could be fixed like this if we really need it:

```diff
diff --git a/modules/charset/escape_stream.go b/modules/charset/escape_stream.go
index 823b63513..fcf1ffbc1 100644
--- a/modules/charset/escape_stream.go
+++ b/modules/charset/escape_stream.go
@@ -20,6 +20,9 @@ import (
 var defaultWordRegexp = regexp.MustCompile(`(-?\d*\.\d\w*)|([^\` + "`" + `\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s\x00-\x1f]+)`)

 func NewEscapeStreamer(locale translation.Locale, next HTMLStreamer, allowed ...rune) HTMLStreamer {
+       sort.Slice(allowed, func(i, j int) bool {
+               return allowed[i] < allowed[j]
+       })
        return &escapeStreamer{
                escaped:                 &EscapeStatus{},
                PassthroughHTMLStreamer: *NewPassthroughStreamer(next),
@@ -284,14 +287,8 @@ func (e *escapeStreamer) runeTypes(runes ...rune) (types []runeType, confusables
 }

 func (e *escapeStreamer) isAllowed(r rune) bool {
-       if len(e.allowed) == 0 {
-               return false
-       }
-       if len(e.allowed) == 1 {
-               return e.allowed[0] == r
-       }
-
-       return sort.Search(len(e.allowed), func(i int) bool {
+       i := sort.Search(len(e.allowed), func(i int) bool {
                return e.allowed[i] >= r
-       }) >= 0
+       })
+       return i < len(e.allowed) && e.allowed[i] == r
 }
```

But I don't think so, a map is better to do it.

20 months agoMake clone URL use current page's host (#22808)
wxiaoguang [Thu, 9 Feb 2023 09:29:13 +0000 (17:29 +0800)]
Make clone URL use current page's host (#22808)

Follow #21986

Even if the ROOT_URL is incorrect, the clone URL on the UI should be
correct.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agochange org_type.go to visible_type.go and fix the notes (#22752)
yp05327 [Thu, 9 Feb 2023 06:40:34 +0000 (15:40 +0900)]
change org_type.go to visible_type.go and fix the notes (#22752)

It seems `VisibleType` is only designed for org at first. But it is also
used by user's visibility now.
So I think `org_type.go` can be changed to `visible_type.go`.

20 months agoImprove notification and stopwatch styles (#22169)
silverwind [Thu, 9 Feb 2023 05:42:18 +0000 (06:42 +0100)]
Improve notification and stopwatch styles (#22169)

- Add dot-style indicators to notification and time tracker
- Slightly reduce whitespace between right-aligned icons
- Move notification icon to right on mobile
- Switch menu icon to SVG

<img width="270" alt="Screenshot 2022-12-19 at 19 40 32"
src="https://user-images.githubusercontent.com/115237/208496795-ce8734a0-f109-47b7-8eb8-96931e867b23.png">
<img width="607" alt="Screenshot 2022-12-19 at 19 41 04"
src="https://user-images.githubusercontent.com/115237/208496797-2ff68197-f520-4174-927e-ead15addd63e.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix blame view missing lines (#22826)
Brecht Van Lommel [Thu, 9 Feb 2023 03:51:02 +0000 (04:51 +0100)]
Fix blame view missing lines (#22826)

Creating a new buffered reader for every part of the blame can miss
lines, as it will read and buffer bytes that the next buffered reader
will not get.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoLoad issue before accessing index in merge message (#22822)
John Olheiser [Thu, 9 Feb 2023 02:47:52 +0000 (20:47 -0600)]
Load issue before accessing index in merge message (#22822)

Fixes #22821

Signed-off-by: jolheiser <john.olheiser@gmail.com>
20 months agoinclude build info in Prometheus metrics (#22819)
Michal [Wed, 8 Feb 2023 17:54:01 +0000 (18:54 +0100)]
include build info in Prometheus metrics (#22819)

Related to: https://github.com/go-gitea/gitea/issues/18061

This PR adds build info to the Prometheus metrics. This includes:
- goarch: https://pkg.go.dev/runtime#GOARCH
- goos: https://pkg.go.dev/runtime#pkg-constants
- goversion: https://pkg.go.dev/runtime#Version
- gitea version: just exposes the existing
code.gitea.io/gitea/modules/setting.AppVer

It's a similar approach to what some other Golang projects are doing,
e.g. Prometheus:
https://github.com/prometheus/common/blob/main/version/info.go

example /metrics response from Prometheus:
```
# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build.
# TYPE prometheus_build_info gauge
prometheus_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.19.4",revision="c0d8a56c69014279464c0e15d8bfb0e153af0dab",version="2.41.0"} 1
```

/metrics response from gitea with this PR:
```
# HELP gitea_build_info Build information
# TYPE gitea_build_info gauge
gitea_build_info{goarch="amd64",goos="linux",goversion="go1.20",version="2c6cc0b8c"} 1
```

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
<!--

Please check the following:

1. Make sure you are targeting the `main` branch, pull requests on
release branches are only allowed for bug fixes.
2. Read contributing guidelines:
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting
(if any)

-->

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
20 months agoFix rerun button of Actions (#22798)
Jason Song [Wed, 8 Feb 2023 07:55:57 +0000 (15:55 +0800)]
Fix rerun button of Actions (#22798)

When clicking the return button, the page should be refreshed. However,
the browser may cancel the previous fetch request, and it fails to rerun
the job. It's easier to reproduce the bug in Safari or Firefox than
Chrome for some reason.

<img width="384" alt="image"
src="https://user-images.githubusercontent.com/9418365/217142792-a783f9a1-7089-44db-b7d8-46c46c72d284.png">

<img width="752" alt="image"
src="https://user-images.githubusercontent.com/9418365/217132406-b8381b63-b323-474e-935b-2596b1b5c046.png">

20 months agoMap OIDC groups to Orgs/Teams (#21441)
KN4CK3R [Wed, 8 Feb 2023 06:44:42 +0000 (07:44 +0100)]
Map OIDC groups to Orgs/Teams (#21441)

Fixes #19555

Test-Instructions:
https://github.com/go-gitea/gitea/pull/21441#issuecomment-1419438000

This PR implements the mapping of user groups provided by OIDC providers
to orgs teams in Gitea. The main part is a refactoring of the existing
LDAP code to make it usable from different providers.

Refactorings:
- Moved the router auth code from module to service because of import
cycles
- Changed some model methods to take a `Context` parameter
- Moved the mapping code from LDAP to a common location

I've tested it with Keycloak but other providers should work too. The
JSON mapping format is the same as for LDAP.

![grafik](https://user-images.githubusercontent.com/1666336/195634392-3fc540fc-b229-4649-99ac-91ae8e19df2d.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix links for the menus in the view file page (#22795)
wxiaoguang [Tue, 7 Feb 2023 16:08:44 +0000 (00:08 +0800)]
Fix links for the menus in the view file page (#22795)

20 months agoFix restore repo bug, clarify the problem of ForeignIndex (#22776)
wxiaoguang [Tue, 7 Feb 2023 01:18:52 +0000 (09:18 +0800)]
Fix restore repo bug, clarify the problem of ForeignIndex (#22776)

Fix #22581

TLDR: #18446 made a mess with ForeignIndex and triggered a design
flaw/bug of #16356, then a quick patch #21271 helped #18446, then the
the bug was re-triggered by #21721 .

Related:
* #16356
* BasicIssueContext
https://github.com/go-gitea/gitea/pull/16356/files#diff-7938eb670d42a5ead6b08121e16aa4537a4d716c1cf37923c70470020fb9d036R16-R27
* #18446
* If some issues were dumped without ForeignIndex, then they would be
imported as ForeignIndex=0
https://github.com/go-gitea/gitea/pull/18446/files#diff-1624a3e715d8fc70edf2db1630642b7d6517f8c359cc69d58c3958b34ba4ce5eR38-R39
* #21271
* It patched the above bug (somewhat), made the issues without
ForeignIndex could have the same value as LocalIndex
* #21721
    * It re-triggered the zero-ForeignIndex bug.

ps: I am not sure whether the changes in `GetForeignIndex` are ideal (at
least, now it has almost the same behavior as BasicIssueContext in
#16356), it's just a quick fix. Feel free to edit on this PR directly or
replace it.

Co-authored-by: zeripath <art27@cantab.net>
20 months agoGrammar fix (#22790)
Peyton Duncan [Mon, 6 Feb 2023 22:05:59 +0000 (14:05 -0800)]
Grammar fix (#22790)

Noticed a minor grammatical error.

20 months agoUse link in UI which returned a relative url but not html_url which contains an absol...
Lunny Xiao [Mon, 6 Feb 2023 18:09:18 +0000 (02:09 +0800)]
Use link in UI which returned a relative url but not html_url which contains an absolute url (#21986)

partially fix #19345

This PR add some `Link` methods for different objects. The `Link`
methods are not different from `HTMLURL`, they are lack of the absolute
URL. And most of UI `HTMLURL` have been replaced to `Link` so that users
can visit them from a different domain or IP.

This PR also introduces a new javascript configuration
`window.config.reqAppUrl` which is different from `appUrl` which is
still an absolute url but the domain has been replaced to the current
requested domain.

20 months agoAdd repo adoption to FAQ (#22778)
John Olheiser [Mon, 6 Feb 2023 16:20:20 +0000 (10:20 -0600)]
Add repo adoption to FAQ (#22778)

This should be a simple set of steps to achieve
repo adoption.

20 months agoUse import of OCI structs (#22765)
KN4CK3R [Mon, 6 Feb 2023 10:07:09 +0000 (11:07 +0100)]
Use import of OCI structs (#22765)

Fixes #22758

Otherwise we would need to rewrite the structs in `oci.go`.

20 months agoUpdate gogs upgrade information (#22777)
John Olheiser [Mon, 6 Feb 2023 06:37:18 +0000 (00:37 -0600)]
Update gogs upgrade information (#22777)

It seems that migrating from Gogs `0.12.x` and above may require more
work as time goes on and the projects continue to diverge.

This PR updates the docs to make it more clear.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
20 months agoAdd CLI option tenant ID for oauth2 source (#22769)
Adi [Mon, 6 Feb 2023 04:12:13 +0000 (05:12 +0100)]
Add CLI option tenant ID for oauth2 source (#22769)

Fixes #22713

20 months agoRefactor legacy strange git operations (#22756)
wxiaoguang [Mon, 6 Feb 2023 02:23:17 +0000 (10:23 +0800)]
Refactor legacy strange git operations (#22756)

During the refactoring of the git module, I found there were some
strange operations. This PR tries to fix 2 of them

1. The empty argument `--` in repo_attribute.go, which was introduced by
#16773. It seems unnecessary because nothing else would be added later.
2. The complex git service logic in repo/http.go.
* Before: the `hasAccess` only allow `service == "upload-pack" ||
service == "receive-pack"`
* After: unrelated code is removed. No need to call ToTrustedCmdArgs
anymore.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoAdd Chef package registry (#22554)
KN4CK3R [Mon, 6 Feb 2023 01:49:21 +0000 (02:49 +0100)]
Add Chef package registry (#22554)

This PR implements a [Chef registry](https://chef.io/) to manage
cookbooks. This package type was a bit complicated because Chef uses RSA
signed requests as authentication with the registry.

![grafik](https://user-images.githubusercontent.com/1666336/213747995-46819fd8-c3d6-45a2-afd4-a4c3c8505a4a.png)

![grafik](https://user-images.githubusercontent.com/1666336/213748145-d01c9e81-d4dd-41e3-a3cc-8241862c3166.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agouse drone secrets for s3 config (#22770)
techknowlogick [Sun, 5 Feb 2023 21:42:48 +0000 (16:42 -0500)]
use drone secrets for s3 config (#22770)

20 months agoremove update language in ProfilePost (#22748)
yp05327 [Sun, 5 Feb 2023 16:06:26 +0000 (01:06 +0900)]
remove update language in ProfilePost (#22748)

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

Change language has been moved to `UpdateUserLang`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoSet PR for issue when load attributes for PRs (#22766)
Jason Song [Sun, 5 Feb 2023 14:24:43 +0000 (22:24 +0800)]
Set PR for issue when load attributes for PRs (#22766)

A missing patch for #22650.

20 months agoFix time to NotifyPullRequestSynchronized (#22650)
Jason Song [Sun, 5 Feb 2023 11:57:38 +0000 (19:57 +0800)]
Fix time to NotifyPullRequestSynchronized (#22650)

Should call `PushToBaseRepo` before
`notification.NotifyPullRequestSynchronized`.

Or the notifier will get an old commit when reading branch
`pull/xxx/head`.

Found by ~#21937~ #22679.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoAdd Cargo package registry (#21888)
KN4CK3R [Sun, 5 Feb 2023 10:12:31 +0000 (11:12 +0100)]
Add Cargo package registry (#21888)

This PR implements a [Cargo registry](https://doc.rust-lang.org/cargo/)
to manage Rust packages. This package type was a little bit more
complicated because Cargo needs an additional Git repository to store
its package index.

Screenshots:

![grafik](https://user-images.githubusercontent.com/1666336/203102004-08d812ac-c066-4969-9bda-2fed818554eb.png)

![grafik](https://user-images.githubusercontent.com/1666336/203102141-d9970f14-dca6-4174-b17a-50ba1bd79087.png)

![grafik](https://user-images.githubusercontent.com/1666336/203102244-dc05743b-78b6-4d97-998e-ef76341a978f.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoAdd new captcha: cloudflare turnstile (#22369)
ByLCY [Sun, 5 Feb 2023 07:29:03 +0000 (15:29 +0800)]
Add new captcha: cloudflare turnstile (#22369)

Added a new captcha(cloudflare turnstile) and its corresponding
document. Cloudflare turnstile official instructions are here:
https://developers.cloudflare.com/turnstile

Signed-off-by: ByLCY <bylcy@bylcy.dev>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoadd default user visibility to cli command "admin user create" (#22750)
yp05327 [Sat, 4 Feb 2023 17:35:04 +0000 (02:35 +0900)]
add default user visibility to cli command "admin user create" (#22750)

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

20 months agoShow all projects, not just repo projects and open/closed projects (#22640)
Lunny Xiao [Sat, 4 Feb 2023 14:35:08 +0000 (22:35 +0800)]
Show all projects, not just repo projects and open/closed projects  (#22640)

This PR fixes two problems. One is when filter repository issues, only
repository level projects are listed. Another is if you list open
issues, only open projects will be displayed in filter options and if
you list closed issues, only closed projects will be displayed in filter
options.

In this PR, both repository level and org/user level projects will be
displayed in filter, and both open and closed projects will be listed as
filter items.

---------

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
20 months agoRemove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
delvh [Sat, 4 Feb 2023 13:26:38 +0000 (14:26 +0100)]
Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)

Every user can already disable the filter manually, so the explicit
setting is absolutely useless and only complicates the logic.

Previously, there was also unexpected behavior when multiple query
parameters were present.

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoEscape path for the file list (#22741)
wxiaoguang [Sat, 4 Feb 2023 10:30:55 +0000 (18:30 +0800)]
Escape path for the file list (#22741)

Fix #22740

20 months agoRepositories: by default disable all units except code and pulls on forks (#22541)
techknowlogick [Sat, 4 Feb 2023 06:48:38 +0000 (01:48 -0500)]
Repositories: by default disable all units except code and pulls on forks (#22541)

Most of the time forks are used for contributing code only, so not
having
issues, projects, release and packages is a better default for such
cases.
They can still be enabled in the settings.

A new option `DEFAULT_FORK_REPO_UNITS` is added to configure the default
units on forks.

Also add missing `repo.packages` unit to documentation.

code by: @brechtvl

## :warning: BREAKING :warning:

When forking a repository, the fork will now have issues, projects,
releases, packages and wiki disabled. These can be enabled in the
repository settings afterwards. To change back to the previous default
behavior, configure `DEFAULT_FORK_REPO_UNITS` to be the same value as
`DEFAULT_REPO_UNITS`.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
20 months agoFix color of tertiary button on dark theme (#22739)
silverwind [Sat, 4 Feb 2023 03:17:43 +0000 (04:17 +0100)]
Fix color of tertiary button on dark theme (#22739)

Before:
<img width="266" alt="Screenshot 2023-02-03 at 14 07 34"
src="https://user-images.githubusercontent.com/115237/216611151-92e98305-c4b5-42f3-b2e2-8b1b805fa644.png">

After:
<img width="271" alt="Screenshot 2023-02-03 at 14 07 52"
src="https://user-images.githubusercontent.com/115237/216611156-878a8a75-39a1-415b-9b6d-4f035985444e.png">

This is the only instance of such a button in all templates.

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoRefactor git command package to improve security and maintainability (#22678)
wxiaoguang [Sat, 4 Feb 2023 02:30:43 +0000 (10:30 +0800)]
Refactor git command package to improve security and maintainability (#22678)

This PR follows #21535 (and replace #22592)

## Review without space diff

https://github.com/go-gitea/gitea/pull/22678/files?diff=split&w=1

## Purpose of this PR

1. Make git module command completely safe (risky user inputs won't be
passed as argument option anymore)
2. Avoid low-level mistakes like
https://github.com/go-gitea/gitea/pull/22098#discussion_r1045234918
3. Remove deprecated and dirty `CmdArgCheck` function, hide the `CmdArg`
type
4. Simplify code when using git command

## The main idea of this PR

* Move the `git.CmdArg` to the `internal` package, then no other package
except `git` could use it. Then developers could never do
`AddArguments(git.CmdArg(userInput))` any more.
* Introduce `git.ToTrustedCmdArgs`, it's for user-provided and already
trusted arguments. It's only used in a few cases, for example: use git
arguments from config file, help unit test with some arguments.
* Introduce `AddOptionValues` and `AddOptionFormat`, they make code more
clear and simple:
    * Before: `AddArguments("-m").AddDynamicArguments(message)`
    * After: `AddOptionValues("-m", message)`
    * -
* Before: `AddArguments(git.CmdArg(fmt.Sprintf("--author='%s <%s>'",
sig.Name, sig.Email)))`
* After: `AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email)`

## FAQ

### Why these changes were not done in #21535 ?

#21535 is mainly a search&replace, it did its best to not change too
much logic.

Making the framework better needs a lot of changes, so this separate PR
is needed as the second step.

### The naming of `AddOptionXxx`

According to git's manual, the `--xxx` part is called `option`.

### How can it guarantee that `internal.CmdArg` won't be not misused?

Go's specification guarantees that. Trying to access other package's
internal package causes compilation error.

And, `golangci-lint` also denies the git/internal package. Only the
`git/command.go` can use it carefully.

### There is still a `ToTrustedCmdArgs`, will it still allow developers
to make mistakes and pass untrusted arguments?

Generally speaking, no. Because when using `ToTrustedCmdArgs`, the code
will be very complex (see the changes for examples). Then developers and
reviewers can know that something might be unreasonable.

### Why there was a `CmdArgCheck` and why it's removed?

At the moment of #21535, to reduce unnecessary changes, `CmdArgCheck`
was introduced as a hacky patch. Now, almost all code could be written
as `cmd := NewCommand(); cmd.AddXxx(...)`, then there is no need for
`CmdArgCheck` anymore.

### Why many codes for `signArg == ""` is deleted?

Because in the old code, `signArg` could never be empty string, it's
either `-S[key-id]` or `--no-gpg-sign`. So the `signArg == ""` is just
dead code.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoImprove trace logging for pulls and processes (#22633)
zeripath [Fri, 3 Feb 2023 23:11:48 +0000 (23:11 +0000)]
Improve trace logging for pulls and processes (#22633)

Our trace logging is far from perfect and is difficult to follow.

This PR:

* Add trace logging for process manager add and remove.
* Fixes an errant read file for git refs in getMergeCommit
* Brings in the pullrequest `String` and `ColorFormat` methods
introduced in #22568
* Adds a lot more logging in to testPR etc.

Ref #22578

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
20 months agoRemove 'primary' class from tab counter labels (#22687)
Francesco Siddi [Fri, 3 Feb 2023 22:25:55 +0000 (23:25 +0100)]
Remove 'primary' class from tab counter labels (#22687)

Using the primary color for each label counter makes the use of color
redundant, as well as suggesting this is a call to action. Use the base
grey color instead.

![grey_lables](https://user-images.githubusercontent.com/451841/215778889-0d5dddad-353f-4703-a48f-1540080dee26.jpg)

20 months agoUse native error checking with `exec.ErrDot` (#22735)
Yarden Shoham [Fri, 3 Feb 2023 17:22:11 +0000 (19:22 +0200)]
Use native error checking with `exec.ErrDot` (#22735)

This was meant to land in #22073 but was blocked until #22732 was merged

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
20 months agoupdate to build with go1.20 (#22732)
techknowlogick [Fri, 3 Feb 2023 16:23:52 +0000 (11:23 -0500)]
update to build with go1.20 (#22732)

as title

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
20 months agoAdd missed reverse proxy authentication documentation (#22250)
Lunny Xiao [Fri, 3 Feb 2023 10:37:25 +0000 (18:37 +0800)]
Add missed reverse proxy authentication documentation (#22250)

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoUpdate button is shown when a Pull Request is marked WIP - Issue #21740 (#22683)
jladbrook [Fri, 3 Feb 2023 06:24:45 +0000 (06:24 +0000)]
Update button is shown when a Pull Request is marked WIP - Issue #21740 (#22683)

Fix #21740.

Updated the Pull Request template so that the 'Update branch by merge'
button is visible for WIP PR's. Making the behaviour match a non WIP-PR.

Previous WIP page with changes pending on the branch:

![image](https://user-images.githubusercontent.com/1656302/215738307-e68a2f92-5ff8-4f48-a541-35ca81d1f1a4.png)

Updated UI adding the update button:

![image](https://user-images.githubusercontent.com/1656302/215737872-e0e9d712-b7aa-4b90-b7ed-6a92a14fc182.png)

## Notes

* have not removed the **$canAutoMerge** variable from the pull.tmpl on
this
[line](https://github.com/go-gitea/gitea/blob/36dc11869d0401b796a7a3f74627fec842a4a89a/templates/repo/issue/view_content/pull.tmpl#L131)
- doesn't appear to be used elsewhere but wasn't sure
* In order to avoid duplicating code corresponding UI code was added to
a new tmpl file, ```update_branch_by_merge.tmpl``` and is called in two
places from ```pull.tmpl```.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoDo not overwrite empty DefaultBranch (#22708)
Jason Song [Thu, 2 Feb 2023 20:48:48 +0000 (04:48 +0800)]
Do not overwrite empty DefaultBranch (#22708)

Fix #21994.
And fix #19470.

While generating new repo from a template, it does something like
"commit to git repo, re-fetch repo model from DB, and update default
branch if it's empty".

https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/modules/repository/generate.go#L241-L253

Unfortunately, when load repo from DB, the default branch will be set to
`setting.Repository.DefaultBranch` if it's empty:

https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/models/repo/repo.go#L228-L233

I believe it's a very old temporary patch but has been kept for many
years, see:
[2d2d85bb](https://github.com/go-gitea/gitea/commit/2d2d85bb#diff-1851799b06733db4df3ec74385c1e8850ee5aedee70b8b55366910d22725eea8)

I know it's a risk to delete it, may lead to potential behavioral
changes, but we cannot keep the outdated `FIXME` forever. On the other
hand, an empty `DefaultBranch` does make sense: an empty repo doesn't
have one conceptually (actually, Gitea will still set it to
`setting.Repository.DefaultBranch` to make it safer).

20 months agoImprove error report when user passes a private key (#22726)
zeripath [Thu, 2 Feb 2023 18:25:54 +0000 (18:25 +0000)]
Improve error report when user passes a private key (#22726)

The error reported when a user passes a private ssh key as their ssh
public key is not very nice.

This PR improves this slightly.

Ref #22693

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
20 months agoAdd some comments for recent code (#22725)
wxiaoguang [Thu, 2 Feb 2023 17:39:38 +0000 (01:39 +0800)]
Add some comments for recent code (#22725)

When using the main branch, I found that some changed code didn't have
comments.

This PR adds some comments.

20 months agoFix actions workflow branches match bug (#22724)
Lunny Xiao [Thu, 2 Feb 2023 12:40:08 +0000 (20:40 +0800)]
Fix actions workflow branches match bug (#22724)

caused by #22680

`pushPayload.Ref` and `prPayload.PullRequest.Base.Ref` have the format
like `refs/heads/<branch_name>`, so we need to trim the prefix before
comparing.

20 months agoFix group filter for ldap source sync (#22506)
Pavel Ezhov [Thu, 2 Feb 2023 07:45:00 +0000 (10:45 +0300)]
Fix group filter for ldap source sync (#22506)

There are 2 separate flows of creating a user: authentication and source
sync.
When a group filter is defined, source sync ignores group filter, while
authentication respects it.
With this PR I've fixed this behavior, so both flows now apply this
filter when searching users in LDAP in a unified way.

- Unified LDAP group membership lookup for authentication and source
sync flows
- Replaced custom group membership lookup (used for authentication flow)
with an existing listLdapGroupMemberships method (used for source sync
flow)
- Modified listLdapGroupMemberships and getUserAttributeListedInGroup in
a way group lookup could be called separately
- Added user filtering based on a group membership for a source sync
- Added tests to cover this logic

Co-authored-by: Pavel Ezhov <paejov@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoset user dashboard org visibility to basic (#22706)
yp05327 [Thu, 2 Feb 2023 06:53:14 +0000 (15:53 +0900)]
set user dashboard org visibility to basic (#22706)

Same to https://github.com/go-gitea/gitea/pull/22674 and
https://github.com/go-gitea/gitea/pull/22605

Sorry to create 3 PR to fix this.
I checked all span with class `org-visibility`, i think this is the last
one :)

And I found that private/limited user has no private/limited tag in
dashboard. but org does.
If it is ok i will add this feature in another pr.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix diff UI for unexpandable items (#22700)
wxiaoguang [Thu, 2 Feb 2023 05:39:55 +0000 (13:39 +0800)]
Fix diff UI for unexpandable items (#22700)

Follows #21094

Before:

There are 2 problems:

1. Sometimes, the header starts with a number, sometimes, it starts with
an icon button. It makes the UI look like misaligned.
2. The second item's bottom border is too thick (actually, that's an
empty element with border, which should be hidden as well)
3. (An old problem) the number is not mono-font

![image](https://user-images.githubusercontent.com/2114189/215935944-003fe2d3-69bf-413c-bbae-0a4668a508c3.png)

After:

Fix above problems.

![image](https://user-images.githubusercontent.com/2114189/215944811-b867a20c-110c-47a2-aa52-572a8162a44d.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
20 months agoFix line spacing for plaintext previews (#22699)
crystal [Thu, 2 Feb 2023 04:51:02 +0000 (21:51 -0700)]
Fix line spacing for plaintext previews (#22699)

Adding `<br>` between each line is not necessary since the entire file
is rendered inside a `<pre>`

fixes https://codeberg.org/Codeberg/Community/issues/915

20 months agoSmall refactor for loading PRs (#22652)
Lunny Xiao [Thu, 2 Feb 2023 03:49:28 +0000 (11:49 +0800)]
Small refactor for loading PRs (#22652)

20 months agoAllow setting access token scope by CLI (#22648)
Lukas [Thu, 2 Feb 2023 03:10:37 +0000 (04:10 +0100)]
Allow setting access token scope by CLI (#22648)

Followup for #20908 to allow setting the scopes when creating new access
token via CLI.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
20 months agoAdd main landmark to templates and adjust titles (#22670)
Felipe Leopoldo Sologuren Gutiérrez [Wed, 1 Feb 2023 22:56:10 +0000 (19:56 -0300)]
Add main landmark to templates and adjust titles (#22670)

* Add main aria landmark to templates
 * Adjust some titles to improve understanding of location in navigation

Contributed by @Forgejo

20 months agoFix cache-control header clearing comment text when editing issue (#22604)
Brecht Van Lommel [Wed, 1 Feb 2023 21:28:06 +0000 (22:28 +0100)]
Fix cache-control header clearing comment text when editing issue (#22604)

The `no-store` cache control added in #20432 is causing form input to be
cleared unnecessarily on page reload. Instead use
`max-age=0,private,must-revalidate` which avoids this.

This was particularly a problem when typing a long comment for an issue
and then for example changing the label. The page would be reloaded and
lose the unsubmitted comment.

Fixes #22603

20 months agoEnable `@<user>`- completion popup on the release description textarea (#22359)
delvh [Wed, 1 Feb 2023 19:14:40 +0000 (20:14 +0100)]
Enable `@<user>`- completion popup on the release description textarea (#22359)

For some unknown reason, this was previously disabled.
Additionally removed an unused return value.

20 months agoAdd Conda package registry (#22262)
KN4CK3R [Wed, 1 Feb 2023 18:30:39 +0000 (19:30 +0100)]
Add Conda package registry (#22262)

This PR adds a [Conda](https://conda.io/) package registry.

20 months agoAdd user secrets (#22191)
KN4CK3R [Wed, 1 Feb 2023 12:53:04 +0000 (13:53 +0100)]
Add user secrets (#22191)

Fixes #22183
Replaces #22187

This PR adds secrets for users. I refactored the files for organizations
and repos to use the same logic and templates. I splitted the secrets
from deploy keys again and reverted the fix from #22187.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoAdd missing close bracket in imagediff (#22710)
zeripath [Wed, 1 Feb 2023 11:48:35 +0000 (11:48 +0000)]
Add missing close bracket in imagediff (#22710)

There was a missing `]` in imagediff.js:

```
const $range = $container.find("input[type='range'");
```

This PR simply adds this.

Fix #22702

20 months agoExplain that the no-access team unit does not affect public repositories (#22661)
yp05327 [Wed, 1 Feb 2023 08:14:40 +0000 (17:14 +0900)]
Explain that the no-access team unit does not affect public repositories (#22661)

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

Add explanations to team unit access control.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoFix bugs with WebAuthn preventing sign in and registration. (#22651)
zeripath [Wed, 1 Feb 2023 07:24:10 +0000 (07:24 +0000)]
Fix bugs with WebAuthn preventing sign in and registration. (#22651)

This PR fixes two bugs with Webauthn support:

* There was a longstanding bug within webauthn due to the backend using
URLEncodedBase64 but the javascript using decoding using plain base64.
This causes intermittent issues with users reporting decoding errors.
* Following the recent upgrade to webauthn there was a change in the way
the library expects RPOrigins to be configured. This leads to the
Relying Party Origin not being configured and prevents registration.

Fix #22507

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 months agoAdd more events details supports for actions (#22680)
Lunny Xiao [Wed, 1 Feb 2023 05:32:46 +0000 (13:32 +0800)]
Add more events details supports for actions (#22680)

#21937 implemented only basic events based on name because of `act`'s
limitation. So I sent a PR to parse all possible events details in
https://gitea.com/gitea/act/pulls/11 and it merged. The ref
documentation is
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

This PR depends on that and make more detail responses for `push` events
and `pull_request` events. And it lefts more events there for future
PRs.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoImprove checkbox accessibility a bit by adding the title attribute (#22593)
Felipe Leopoldo Sologuren Gutiérrez [Wed, 1 Feb 2023 01:43:06 +0000 (22:43 -0300)]
Improve checkbox accessibility a bit by adding the title attribute (#22593)

EDIT: The main change of this PR was resolved by #22599. This
complements that PR for some cases without label and complicated layout
to be added.

NOTE: Contributed by @Forgejo.

20 months agoAdd repository setting to enable/disable releases unit (#22671)
Brecht Van Lommel [Wed, 1 Feb 2023 01:31:19 +0000 (02:31 +0100)]
Add repository setting to enable/disable releases unit (#22671)

To go along with similar settings for issues, pulls, projects, packages.

20 months agoUse relative url in actions view (#22675)
Jason Song [Tue, 31 Jan 2023 22:46:10 +0000 (06:46 +0800)]
Use relative url in actions view (#22675)

Use relative url in actions view.

20 months agoFix ref to trigger Actions (#22679)
Jason Song [Tue, 31 Jan 2023 22:45:25 +0000 (06:45 +0800)]
Fix ref to trigger Actions (#22679)

If triggered by PR, the ref should be `pull/<index>/head` instead of
`repo.DefaultBranch`.

And improve UI:

<img width="493" alt="image"
src="https://user-images.githubusercontent.com/9418365/215731280-312564f2-2450-45d0-b986-1accb0670976.png">

Related to #21937.

20 months agoRootless Docker - Mistake with the repo-avatars parent folder name (#22637)
Melroy van den Berg [Tue, 31 Jan 2023 22:42:48 +0000 (23:42 +0100)]
Rootless Docker - Mistake with the repo-avatars parent folder name (#22637)

There was a mistake when choosing the structure for the repo avatars parent folder and it added a spurious /gitea.

The `data` directory should contain folders like:

  - `attachments/`
  - `avatars/`
  - `log/`
  - `repo-avatars/`

20 months agoFix missing title and filter in issue sidebar project menu (#22557)
Brecht Van Lommel [Tue, 31 Jan 2023 22:40:38 +0000 (23:40 +0100)]
Fix missing title and filter in issue sidebar project menu (#22557)

These exist in the new issue form but were seemingly forgotten here.

20 months agoFix wrong hint when deleting a branch successfully from pull request UI (#22673)
Lunny Xiao [Tue, 31 Jan 2023 22:11:48 +0000 (06:11 +0800)]
Fix wrong hint when deleting a branch successfully from pull request UI (#22673)

Fix #18785

20 months agoAdd Contributed backport command (#22643)
zeripath [Tue, 31 Jan 2023 22:10:54 +0000 (22:10 +0000)]
Add Contributed backport command (#22643)

This PR provides a contributed backport command to help create backports
for Gitea.

It represents a significant improvement on my previously described
shell-script.

It can be installed using `go install contrib/backport/backport.go`.

Signed-off-by: Andrew Thornton <art27@cantab.net>
20 months agoFix typo in command-line.en-us.md (#22681)
Ivan Maximov [Tue, 31 Jan 2023 21:43:39 +0000 (00:43 +0300)]
Fix typo in command-line.en-us.md (#22681)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix typo in linked-references.en-us.md (#22682)
Ivan Maximov [Tue, 31 Jan 2023 21:43:27 +0000 (00:43 +0300)]
Fix typo in linked-references.en-us.md (#22682)

20 months agoFix typo in guidelines-backend.en-us.md (#22690)
Ivan Maximov [Tue, 31 Jan 2023 21:43:12 +0000 (00:43 +0300)]
Fix typo in guidelines-backend.en-us.md (#22690)

20 months agoFix typo in storage.en-us.md (#22694)
Ivan Maximov [Tue, 31 Jan 2023 21:42:41 +0000 (00:42 +0300)]
Fix typo in storage.en-us.md (#22694)

20 months agoHide collapse icon in diff with no lines (#21094)
JakobDev [Tue, 31 Jan 2023 17:40:22 +0000 (18:40 +0100)]
Hide collapse icon in diff with no lines (#21094)

Sometimes (e.g. renaming a file) nothing of the content is changed. In
this case, it makes no sense to show the collapse icon in a diff.

20 months agoFixes accessibility behavior of Watching, Staring and Fork buttons (#22634)
Felipe Leopoldo Sologuren Gutiérrez [Tue, 31 Jan 2023 15:28:43 +0000 (12:28 -0300)]
Fixes accessibility behavior of Watching, Staring and Fork buttons (#22634)

Add tabindex to buttons of repository views.

20 months agoDisable test for incoming email (#22686)
KN4CK3R [Tue, 31 Jan 2023 13:56:22 +0000 (14:56 +0100)]
Disable test for incoming email (#22686)

Disable this test for the moment because the used imap container image
seems unstable which results in many failed CI builds.

Co-authored-by: Jason Song <i@wolfogre.com>
20 months agoRemove label color from global issue filters (#22660)
Francesco Siddi [Tue, 31 Jan 2023 12:58:34 +0000 (13:58 +0100)]
Remove label color from global issue filters (#22660)

The use of ui colors (red, green, etc) should be limited to actionable
or dismissable entries. Before this commit, a green/red label was used
to display issues count on each repository. This did not add any
meaningful information to the list.

Removing the label reduces ambiguity and makes the list easier to scan
visually.

![label_compare](https://user-images.githubusercontent.com/451841/215360696-a881b765-207d-4ffa-8bec-398f8e5dab1e.jpg)

---------

Co-authored-by: delvh <dev.lh@web.de>
20 months agoUse correct captured group range when parsing cross-reference (#22672)
wxiaoguang [Tue, 31 Jan 2023 09:08:05 +0000 (17:08 +0800)]
Use correct captured group range when parsing cross-reference (#22672)

Fixes #22666 (Replace #22668)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: zeripath <art27@cantab.net>
20 months agoset user visibility class to basic (#22674)
yp05327 [Tue, 31 Jan 2023 07:05:25 +0000 (16:05 +0900)]
set user visibility class to basic (#22674)

Same to https://github.com/go-gitea/gitea/pull/22605

![user
package](https://user-images.githubusercontent.com/18380374/215669905-71fe01c3-c011-4867-97a6-3df5f940a6bf.PNG)
![user
projects](https://user-images.githubusercontent.com/18380374/215669909-1a4f74f1-bbde-4913-9ba5-51c44cc63862.PNG)

These two page are both used at user and org, so if i fixed the org
page, the user page will be also be fixed.

20 months agoFix README TOC links (#22577)
crystal [Tue, 31 Jan 2023 05:21:29 +0000 (22:21 -0700)]
Fix README TOC links (#22577)

Fixes anchored markup links by adding `user-content-` (which is
prepended to IDs)

Closes https://codeberg.org/Codeberg/Community/issues/894

20 months agoImplement actions (#21937)
Jason Song [Tue, 31 Jan 2023 01:45:19 +0000 (09:45 +0800)]
Implement actions (#21937)

Close #13539.

Co-authored by: @lunny @appleboy @fuxiaohei and others.

Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner

### Summary

The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:

- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.

**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.

### ⚠️ Breaking

`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.

### Some important reviews

- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868

### What it looks like

<details>

#### Manage runners

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">

#### List runs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">

#### View logs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">

</details>

### How to try it

<details>

#### 1. Start Gitea

Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).

Add additional configurations in `app.ini` to enable Actions:

```ini
[actions]
ENABLED = true
```

Start it.

If all is well, you'll see the management page of runners:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">

#### 2. Start runner

Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.

If all is well, you'll see a new runner has been added:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">

#### 3. Enable actions for a repo

Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">

If all is well, you'll see a new tab "Actions":

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">

#### 4. Upload workflow files

Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:

```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "🍏 This job's status is ${{ job.status }}."
```

If all is well, you'll see a new run in `Actions` tab:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">

#### 5. Check the logs of jobs

Click a run and you'll see the logs:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">

#### 6. Go on

You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.

Come on, PRs are welcome.

</details>

See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)

---------

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
20 months agoPull request yaml template support for including commit body in a field (#22629)
Brecht Van Lommel [Mon, 30 Jan 2023 14:39:07 +0000 (15:39 +0100)]
Pull request yaml template support for including commit body in a field (#22629)

When using a markdown template the commit body is prepended to text in
the description. This adds the same functionality for yaml templates,
adding the commit message in a field with id "body".

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoDon't return duplicated users who can create org repo (#22560)
Gusted [Mon, 30 Jan 2023 10:12:45 +0000 (11:12 +0100)]
Don't return duplicated users who can create org repo (#22560)

- Currently the function `GetUsersWhoCanCreateOrgRepo` uses a query that
is able to have duplicated users in the result, this is can happen under
the condition that a user is in team that either is the owner team or
has permission to create organization repositories.
- Add test code to simulate the above condition for user 3,
[`TestGetUsersWhoCanCreateOrgRepo`](https://github.com/go-gitea/gitea/blob/a1fcb1cfb84fd6b36c8fe9fd56588119fa4377bc/models/organization/org_test.go#L435)
is the test function that tests for this.
- The fix is quite trivial use a map keyed by user id in order to drop
duplicates.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix poor alignment of organization description on organization home page (#22656)
Brecht Van Lommel [Mon, 30 Jan 2023 08:16:12 +0000 (09:16 +0100)]
Fix poor alignment of organization description on organization home page (#22656)

Don't generate nested `<p>`, use `<div>` like description on the user
profile page.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoIssues: support setting issue template field values with query (#22545)
techknowlogick [Mon, 30 Jan 2023 04:36:04 +0000 (23:36 -0500)]
Issues: support setting issue template field values with query (#22545)

20 months agoAdd support for commit cross references (#22645)
KN4CK3R [Mon, 30 Jan 2023 01:50:01 +0000 (02:50 +0100)]
Add support for commit cross references (#22645)

Fixes #22628

This PR adds cross references for commits by using the format
`owner/repo@commit` . References are rendered like
[go-gitea/lgtm@6fe88302](#dummy).

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoFix missing message in git hook when pull requests disabled on fork (#22625)
Brecht Van Lommel [Sun, 29 Jan 2023 21:00:10 +0000 (22:00 +0100)]
Fix missing message in git hook when pull requests disabled on fork (#22625)

And also the other way around, it would show an non-working URL in the
message when pull requests are disabled on the base repository but
enabled on the fork.

20 months agoCheck quota limits for container uploads (#22450)
KN4CK3R [Sun, 29 Jan 2023 17:34:29 +0000 (18:34 +0100)]
Check quota limits for container uploads (#22450)

The test coverage has revealed that container packages were not checked
against the quota limits.

20 months agoConsume hcaptcha and pwn deps (#22610)
John Olheiser [Sun, 29 Jan 2023 15:49:51 +0000 (09:49 -0600)]
Consume hcaptcha and pwn deps (#22610)

This PR just consumes the
[hcaptcha](https://gitea.com/jolheiser/hcaptcha) and
[haveibeenpwned](https://gitea.com/jolheiser/pwn) modules directly into
Gitea.

Also let this serve as a notice that I'm fine with transferring my
license (which was already MIT) from my own name to "The Gitea Authors".

Signed-off-by: jolheiser <john.olheiser@gmail.com>
20 months agoIssues: add Project filter to issues list and search (#22544)
techknowlogick [Sun, 29 Jan 2023 03:45:29 +0000 (22:45 -0500)]
Issues: add Project filter to issues list and search (#22544)

Currently only a single project like milestone, not multiple like
labels.

Implements #14298

Code by @brechtvl

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
20 months agoImprove accessibility of navigation bar and footer (#22635)
Felipe Leopoldo Sologuren Gutiérrez [Sun, 29 Jan 2023 01:29:10 +0000 (22:29 -0300)]
Improve accessibility of navigation bar and footer (#22635)

Added ARIA navigation landmark to navigation bar and aria label for both
nav bar and footer.

Contributed by @forgejo.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
20 months agoSupport system hook API (#14537)
Lunny Xiao [Sat, 28 Jan 2023 18:12:10 +0000 (02:12 +0800)]
Support system hook API (#14537)

This add system hook API