Skip to content

Commit dee12a7

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix restore repo bug, clarify the problem of ForeignIndex (go-gitea#22776) Grammar fix (go-gitea#22790) Use link in UI which returned a relative url but not html_url which contains an absolute url (go-gitea#21986) Add repo adoption to FAQ (go-gitea#22778) Use import of OCI structs (go-gitea#22765) Update gogs upgrade information (go-gitea#22777) Add CLI option tenant ID for oauth2 source (go-gitea#22769) Refactor legacy strange git operations (go-gitea#22756) Add Chef package registry (go-gitea#22554) use drone secrets for s3 config (go-gitea#22770) remove update language in ProfilePost (go-gitea#22748) Set PR for issue when load attributes for PRs (go-gitea#22766) Fix time to NotifyPullRequestSynchronized (go-gitea#22650)
2 parents 9c3cd58 + d5fa2e7 commit dee12a7

File tree

98 files changed

+2159
-517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2159
-517
lines changed

.drone.yml

+30-12
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,16 @@ steps:
763763
image: woodpeckerci/plugin-s3:latest
764764
pull: always
765765
settings:
766-
acl: public-read
767-
bucket: gitea-artifacts
768-
endpoint: https://ams3.digitaloceanspaces.com
769-
path_style: true
766+
acl:
767+
from_secret: aws_s3_acl
768+
region:
769+
from_secret: aws_s3_region
770+
bucket:
771+
from_secret: aws_s3_bucket
772+
endpoint:
773+
from_secret: aws_s3_endpoint
774+
path_style:
775+
from_secret: aws_s3_path_style
770776
source: "dist/release/*"
771777
strip_prefix: dist/release/
772778
target: "/gitea/${DRONE_BRANCH##release/v}"
@@ -784,10 +790,16 @@ steps:
784790
- name: release-main
785791
image: woodpeckerci/plugin-s3:latest
786792
settings:
787-
acl: public-read
788-
bucket: gitea-artifacts
789-
endpoint: https://ams3.digitaloceanspaces.com
790-
path_style: true
793+
acl:
794+
from_secret: aws_s3_acl
795+
region:
796+
from_secret: aws_s3_region
797+
bucket:
798+
from_secret: aws_s3_bucket
799+
endpoint:
800+
from_secret: aws_s3_endpoint
801+
path_style:
802+
from_secret: aws_s3_path_style
791803
source: "dist/release/*"
792804
strip_prefix: dist/release/
793805
target: /gitea/main
@@ -886,10 +898,16 @@ steps:
886898
image: woodpeckerci/plugin-s3:latest
887899
pull: always
888900
settings:
889-
acl: public-read
890-
bucket: gitea-artifacts
891-
endpoint: https://ams3.digitaloceanspaces.com
892-
path_style: true
901+
acl:
902+
from_secret: aws_s3_acl
903+
region:
904+
from_secret: aws_s3_region
905+
bucket:
906+
from_secret: aws_s3_bucket
907+
endpoint:
908+
from_secret: aws_s3_endpoint
909+
path_style:
910+
from_secret: aws_s3_path_style
893911
source: "dist/release/*"
894912
strip_prefix: dist/release/
895913
target: "/gitea/${DRONE_TAG##v}"

assets/go-licenses.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/admin.go

+11
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ var (
308308
Value: "false",
309309
Usage: "Use custom URLs for GitLab/GitHub OAuth endpoints",
310310
},
311+
cli.StringFlag{
312+
Name: "custom-tenant-id",
313+
Value: "",
314+
Usage: "Use custom Tenant ID for OAuth endpoints",
315+
},
311316
cli.StringFlag{
312317
Name: "custom-auth-url",
313318
Value: "",
@@ -829,6 +834,7 @@ func parseOAuth2Config(c *cli.Context) *oauth2.Source {
829834
AuthURL: c.String("custom-auth-url"),
830835
ProfileURL: c.String("custom-profile-url"),
831836
EmailURL: c.String("custom-email-url"),
837+
Tenant: c.String("custom-tenant-id"),
832838
}
833839
} else {
834840
customURLMapping = nil
@@ -938,6 +944,7 @@ func runUpdateOauth(c *cli.Context) error {
938944
customURLMapping.AuthURL = oAuth2Config.CustomURLMapping.AuthURL
939945
customURLMapping.ProfileURL = oAuth2Config.CustomURLMapping.ProfileURL
940946
customURLMapping.EmailURL = oAuth2Config.CustomURLMapping.EmailURL
947+
customURLMapping.Tenant = oAuth2Config.CustomURLMapping.Tenant
941948
}
942949
if c.IsSet("use-custom-urls") && c.IsSet("custom-token-url") {
943950
customURLMapping.TokenURL = c.String("custom-token-url")
@@ -955,6 +962,10 @@ func runUpdateOauth(c *cli.Context) error {
955962
customURLMapping.EmailURL = c.String("custom-email-url")
956963
}
957964

965+
if c.IsSet("use-custom-urls") && c.IsSet("custom-tenant-id") {
966+
customURLMapping.Tenant = c.String("custom-tenant-id")
967+
}
968+
958969
oAuth2Config.CustomURLMapping = customURLMapping
959970
source.Cfg = oAuth2Config
960971

custom/conf/app.example.ini

+2
Original file line numberDiff line numberDiff line change
@@ -2460,6 +2460,8 @@ ROUTER = console
24602460
;LIMIT_TOTAL_OWNER_SIZE = -1
24612461
;; Maximum size of a Cargo upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24622462
;LIMIT_SIZE_CARGO = -1
2463+
;; Maximum size of a Chef upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2464+
;LIMIT_SIZE_CHEF = -1
24632465
;; Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24642466
;LIMIT_SIZE_COMPOSER = -1
24652467
;; Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
12141214
- `LIMIT_TOTAL_OWNER_COUNT`: **-1**: Maximum count of package versions a single owner can have (`-1` means no limits)
12151215
- `LIMIT_TOTAL_OWNER_SIZE`: **-1**: Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12161216
- `LIMIT_SIZE_CARGO`: **-1**: Maximum size of a Cargo upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1217+
- `LIMIT_SIZE_CHEF`: **-1**: Maximum size of a Chef upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12171218
- `LIMIT_SIZE_COMPOSER`: **-1**: Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12181219
- `LIMIT_SIZE_CONAN`: **-1**: Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
12191220
- `LIMIT_SIZE_CONDA`: **-1**: Maximum size of a Conda upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)

docs/content/doc/help/faq.en-us.md

+11
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,14 @@ It is highly recommended to back-up your database before running these commands.
449449
If you are using Cloudflare, turn off the auto-minify option in the dashboard.
450450

451451
`Speed` -> `Optimization` -> Uncheck `HTML` within the `Auto-Minify` settings.
452+
453+
## How to adopt repositories from disk
454+
455+
- Add your (bare) repositories to the correct spot for your configuration (`repository.ROOT`), ensuring they are in the correct layout `<REPO_ROOT>/[user]/[repo].git`.
456+
- **Note:** the directory names must be lowercase.
457+
- You can also check `<ROOT_URL>/admin/config` for the repository root path.
458+
- Ensure that the user/org exists that you want to adopt repositories for.
459+
- As an admin, go to `<ROOT_URL>/admin/repos/unadopted` and search.
460+
- Users can also be given similar permissions via config [`ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#repository" >}}).
461+
- If the above steps are done correctly, you should be able to select repositories to adopt.
462+
- If no repositories are found, enable [debug logging]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#repository" >}}) to check for any specific errors.

docs/content/doc/installation/with-docker-rootless.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gitea provides automatically updated Docker images within its Docker Hub organiz
1919
possible to always use the latest stable tag or to use another service that handles updating
2020
Docker images.
2121

22-
The rootless image use Gitea internal SSH to provide Git protocol and doesn't support OpenSSH.
22+
The rootless image uses Gitea internal SSH to provide Git protocol and doesn't support OpenSSH.
2323

2424
This reference setup guides users through the setup based on `docker-compose`, but the installation
2525
of `docker-compose` is out of scope of this documentation. To install `docker-compose` itself, follow
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
date: "2023-01-20T00:00:00+00:00"
3+
title: "Chef Packages Repository"
4+
slug: "packages/chef"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "Chef"
11+
weight: 5
12+
identifier: "chef"
13+
---
14+
15+
# Chef Packages Repository
16+
17+
Publish [Chef](https://chef.io/) cookbooks for your user or organization.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
To work with the Chef package registry, you have to use [`knife`](https://docs.chef.io/workstation/knife/).
26+
27+
## Authentication
28+
29+
The Chef package registry does not use an username:password authentication but signed requests with a private:public key pair.
30+
Visit the package owner settings page to create the necessary key pair.
31+
Only the public key is stored inside Gitea. if you loose access to the private key you must re-generate the key pair.
32+
[Configure `knife`](https://docs.chef.io/workstation/knife_setup/) to use the downloaded private key with your Gitea username as `client_name`.
33+
34+
## Configure the package registry
35+
36+
To [configure `knife`](https://docs.chef.io/workstation/knife_setup/) to use the Gitea package registry add the url to the `~/.chef/config.rb` file.
37+
38+
```
39+
knife[:supermarket_site] = 'https://gitea.example.com/api/packages/{owner}/chef'
40+
```
41+
42+
| Parameter | Description |
43+
| --------- | ----------- |
44+
| `owner` | The owner of the package. |
45+
46+
## Publish a package
47+
48+
To publish a Chef package execute the following command:
49+
50+
```shell
51+
knife supermarket share {package_name}
52+
```
53+
54+
| Parameter | Description |
55+
| -------------- | ----------- |
56+
| `package_name` | The package name. |
57+
58+
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
59+
60+
## Install a package
61+
62+
To install a package from the package registry, execute the following command:
63+
64+
```shell
65+
knife supermarket install {package_name}
66+
```
67+
68+
Optional you can specify the package version:
69+
70+
```shell
71+
knife supermarket install {package_name} {package_version}
72+
```
73+
74+
| Parameter | Description |
75+
| ----------------- | ----------- |
76+
| `package_name` | The package name. |
77+
| `package_version` | The package version. |
78+
79+
## Delete a package
80+
81+
If you want to remove a package from the registry, execute the following command:
82+
83+
```shell
84+
knife supermarket unshare {package_name}
85+
```
86+
87+
Optional you can specify the package version:
88+
89+
```shell
90+
knife supermarket unshare {package_name}/versions/{package_version}
91+
```
92+
93+
| Parameter | Description |
94+
| ----------------- | ----------- |
95+
| `package_name` | The package name. |
96+
| `package_version` | The package version. |

docs/content/doc/packages/overview.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following package managers are currently supported:
2727
| Name | Language | Package client |
2828
| ---- | -------- | -------------- |
2929
| [Cargo]({{< relref "doc/packages/cargo.en-us.md" >}}) | Rust | `cargo` |
30+
| [Chef]({{< relref "doc/packages/chef.en-us.md" >}}) | - | `knife` |
3031
| [Composer]({{< relref "doc/packages/composer.en-us.md" >}}) | PHP | `composer` |
3132
| [Conan]({{< relref "doc/packages/conan.en-us.md" >}}) | C++ | `conan` |
3233
| [Conda]({{< relref "doc/packages/conda.en-us.md" >}}) | - | `conda` |

docs/content/doc/upgrade/from-gogs.en-us.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ Then repeat the procedure, but this time using the [latest release](https://dl.g
8585

8686
## Upgrading from a more recent version of Gogs
8787

88-
Upgrading from a more recent version of Gogs is also possible, but requires a bit more work.
89-
See [#4286](https://github.com/go-gitea/gitea/issues/4286).
88+
Upgrading from a more recent version of Gogs (up to `0.11.x`) may also be possible, but will require a bit more work.
89+
See [#4286](https://github.com/go-gitea/gitea/issues/4286), which includes various Gogs `0.11.x` versions.
90+
91+
Upgrading from Gogs `0.12.x` and above will be increasingly more difficult as the projects diverge further apart in configuration and schema.
9092

9193
## Troubleshooting
9294

docs/content/doc/usage/command-line.en-us.md

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Admin operations:
124124
- `--secret`: Client Secret.
125125
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
126126
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
127+
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
127128
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
128129
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
129130
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).
@@ -147,6 +148,7 @@ Admin operations:
147148
- `--secret`: Client Secret.
148149
- `--auto-discover-url`: OpenID Connect Auto Discovery URL (only required when using OpenID Connect as provider).
149150
- `--use-custom-urls`: Use custom URLs for GitLab/GitHub OAuth endpoints.
151+
- `--custom-tenant-id`: Use custom Tenant ID for OAuth endpoints.
150152
- `--custom-auth-url`: Use a custom Authorization URL (option for GitLab/GitHub).
151153
- `--custom-token-url`: Use a custom Token URL (option for GitLab/GitHub).
152154
- `--custom-profile-url`: Use a custom Profile URL (option for GitLab/GitHub).

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ require (
8282
github.com/niklasfasching/go-org v1.6.5
8383
github.com/oliamb/cutter v0.2.2
8484
github.com/olivere/elastic/v7 v7.0.32
85+
github.com/opencontainers/go-digest v1.0.0
86+
github.com/opencontainers/image-spec v1.1.0-rc2
8587
github.com/pkg/errors v0.9.1
8688
github.com/pquerna/otp v1.4.0
8789
github.com/prometheus/client_golang v1.14.0

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
10091009
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
10101010
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
10111011
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
1012+
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
1013+
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
1014+
github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034=
1015+
github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ=
10121016
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
10131017
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
10141018
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=

models/activities/action.go

+46-5
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,49 @@ func (a *Action) GetRepoAbsoluteLink() string {
223223
return setting.AppURL + url.PathEscape(a.GetRepoUserName()) + "/" + url.PathEscape(a.GetRepoName())
224224
}
225225

226+
// GetCommentHTMLURL returns link to action comment.
227+
func (a *Action) GetCommentHTMLURL() string {
228+
return a.getCommentHTMLURL(db.DefaultContext)
229+
}
230+
231+
func (a *Action) loadComment(ctx context.Context) (err error) {
232+
if a.CommentID == 0 || a.Comment != nil {
233+
return nil
234+
}
235+
a.Comment, err = issues_model.GetCommentByID(ctx, a.CommentID)
236+
return err
237+
}
238+
239+
func (a *Action) getCommentHTMLURL(ctx context.Context) string {
240+
if a == nil {
241+
return "#"
242+
}
243+
_ = a.loadComment(ctx)
244+
if a.Comment != nil {
245+
return a.Comment.HTMLURL()
246+
}
247+
if len(a.GetIssueInfos()) == 0 {
248+
return "#"
249+
}
250+
// Return link to issue
251+
issueIDString := a.GetIssueInfos()[0]
252+
issueID, err := strconv.ParseInt(issueIDString, 10, 64)
253+
if err != nil {
254+
return "#"
255+
}
256+
257+
issue, err := issues_model.GetIssueByID(ctx, issueID)
258+
if err != nil {
259+
return "#"
260+
}
261+
262+
if err = issue.LoadRepo(ctx); err != nil {
263+
return "#"
264+
}
265+
266+
return issue.HTMLURL()
267+
}
268+
226269
// GetCommentLink returns link to action comment.
227270
func (a *Action) GetCommentLink() string {
228271
return a.getCommentLink(db.DefaultContext)
@@ -232,11 +275,9 @@ func (a *Action) getCommentLink(ctx context.Context) string {
232275
if a == nil {
233276
return "#"
234277
}
235-
if a.Comment == nil && a.CommentID != 0 {
236-
a.Comment, _ = issues_model.GetCommentByID(ctx, a.CommentID)
237-
}
278+
_ = a.loadComment(ctx)
238279
if a.Comment != nil {
239-
return a.Comment.HTMLURL()
280+
return a.Comment.Link()
240281
}
241282
if len(a.GetIssueInfos()) == 0 {
242283
return "#"
@@ -257,7 +298,7 @@ func (a *Action) getCommentLink(ctx context.Context) string {
257298
return "#"
258299
}
259300

260-
return issue.HTMLURL()
301+
return issue.Link()
261302
}
262303

263304
// GetBranch returns the action's repository branch.

models/activities/action_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestAction_GetRepoLink(t *testing.T) {
3636
expected := path.Join(setting.AppSubURL, owner.Name, repo.Name)
3737
assert.Equal(t, expected, action.GetRepoLink())
3838
assert.Equal(t, repo.HTMLURL(), action.GetRepoAbsoluteLink())
39-
assert.Equal(t, comment.HTMLURL(), action.GetCommentLink())
39+
assert.Equal(t, comment.HTMLURL(), action.GetCommentHTMLURL())
4040
}
4141

4242
func TestGetFeeds(t *testing.T) {

0 commit comments

Comments
 (0)