Skip to content

Commit 38a0841

Browse files
authored
Merge branch 'main' into bugfix/Fix-the-incorrect-route-path
2 parents 3a06285 + 7046065 commit 38a0841

File tree

356 files changed

+2820
-1945
lines changed

Some content is hidden

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

356 files changed

+2820
-1945
lines changed

.github/workflows/release-nightly.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ on:
55
branches: [ main, release/v* ]
66

77
concurrency:
8-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
group: ${{ github.workflow }}-${{ github.ref }}
99
cancel-in-progress: true
1010

1111
jobs:
1212
nightly-binary:
13-
runs-on: actuated-4cpu-8gb
13+
runs-on: actuated-4cpu-16gb
1414
steps:
1515
- uses: actions/checkout@v3
1616
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
@@ -93,7 +93,7 @@ jobs:
9393
push: true
9494
tags: gitea/gitea:${{ steps.clean_name.outputs.branch }}
9595
nightly-docker-rootless:
96-
runs-on: actuated-4cpu-8gb
96+
runs-on: actuated-4cpu-16gb
9797
steps:
9898
- uses: actions/checkout@v3
9999
# fetch all commits instead of only the last as some branches are long lived and could have many between versions

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ Denys Konovalov <[email protected]> (@denyskon)
5656
Punit Inani <[email protected]> (@puni9869)
5757
CaiCandong <[email protected]> (@caicandong)
5858
Rui Chen <[email protected]> (@chenrui333)
59+
Nanguan Lin <[email protected]> (@lng2020)

cmd/admin_user_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func runCreateUser(c *cli.Context) error {
115115

116116
// If this is the first user being created.
117117
// Take it as the admin and don't force a password update.
118-
if n := user_model.CountUsers(nil); n == 0 {
118+
if n := user_model.CountUsers(ctx, nil); n == 0 {
119119
changePassword = false
120120
}
121121

@@ -146,7 +146,7 @@ func runCreateUser(c *cli.Context) error {
146146
IsRestricted: restricted,
147147
}
148148

149-
if err := user_model.CreateUser(u, overwriteDefault); err != nil {
149+
if err := user_model.CreateUser(ctx, u, overwriteDefault); err != nil {
150150
return fmt.Errorf("CreateUser: %w", err)
151151
}
152152

@@ -156,7 +156,7 @@ func runCreateUser(c *cli.Context) error {
156156
UID: u.ID,
157157
}
158158

159-
if err := auth_model.NewAccessToken(t); err != nil {
159+
if err := auth_model.NewAccessToken(ctx, t); err != nil {
160160
return err
161161
}
162162

cmd/admin_user_generate_access_token.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func runGenerateAccessToken(c *cli.Context) error {
6363
UID: user.ID,
6464
}
6565

66-
exist, err := auth_model.AccessTokenByNameExists(t)
66+
exist, err := auth_model.AccessTokenByNameExists(ctx, t)
6767
if err != nil {
6868
return err
6969
}
@@ -79,7 +79,7 @@ func runGenerateAccessToken(c *cli.Context) error {
7979
t.Scope = accessTokenScope
8080

8181
// create the token
82-
if err := auth_model.NewAccessToken(t); err != nil {
82+
if err := auth_model.NewAccessToken(ctx, t); err != nil {
8383
return err
8484
}
8585

cmd/admin_user_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func runListUsers(c *cli.Context) error {
3333
return err
3434
}
3535

36-
users, err := user_model.GetAllUsers()
36+
users, err := user_model.GetAllUsers(ctx)
3737
if err != nil {
3838
return err
3939
}
@@ -48,7 +48,7 @@ func runListUsers(c *cli.Context) error {
4848
}
4949
}
5050
} else {
51-
twofa := user_model.UserList(users).GetTwoFaStatus()
51+
twofa := user_model.UserList(users).GetTwoFaStatus(ctx)
5252
fmt.Fprintf(w, "ID\tUsername\tEmail\tIsActive\tIsAdmin\t2FA\n")
5353
for _, u := range users {
5454
fmt.Fprintf(w, "%d\t%s\t%s\t%t\t%t\t%t\n", u.ID, u.Name, u.Email, u.IsActive, u.IsAdmin, twofa[u.ID])

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ LEVEL = Info
25622562

25632563
; [actions]
25642564
;; Enable/Disable actions capabilities
2565-
;ENABLED = false
2565+
;ENABLED = true
25662566
;;
25672567
;; Default platform to get action plugins, `github` for `https://github.com`, `self` for the current Gitea instance.
25682568
;DEFAULT_ACTIONS_URL = github

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ PROXY_HOSTS = *.i.8713187.xyz
13841384

13851385
## Actions (`actions`)
13861386

1387-
- `ENABLED`: **false**: Enable/Disable actions capabilities
1387+
- `ENABLED`: **true**: Enable/Disable actions capabilities
13881388
- `DEFAULT_ACTIONS_URL`: **github**: Default platform to get action plugins, `github` for `https://github.com`, `self` for the current Gitea instance.
13891389
- `STORAGE_TYPE`: **local**: Storage type for actions logs, `local` for local disk or `minio` for s3 compatible object storage service, default is `local` or other name defined with `[storage.xxx]`
13901390
- `MINIO_BASE_PATH`: **actions_log/**: Minio base path on the bucket only available when STORAGE_TYPE is `minio`

docs/content/administration/config-cheat-sheet.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ PROXY_HOSTS = *.i.8713187.xyz
13311331

13321332
## Actions (`actions`)
13331333

1334-
- `ENABLED`: **false**:启用/禁用操作功能
1334+
- `ENABLED`: **true**:启用/禁用操作功能
13351335
- `DEFAULT_ACTIONS_URL`: **github**:获取操作插件的默认平台,`github`表示`https://github.com``self`表示当前的 Gitea 实例。
13361336
- `STORAGE_TYPE`: **local**:用于操作日志的存储类型,`local`表示本地磁盘,`minio`表示与S3兼容的对象存储服务,默认为`local`,或者使用定义为`[storage.xxx]`的其他名称。
13371337
- `MINIO_BASE_PATH`: **actions_log/**:Minio存储桶上的基本路径,仅在`STORAGE_TYPE``minio`时可用。

docs/content/installation/from-package.en-us.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Following the [deployment from binary](installation/from-binary.md) guide may wo
2424
but is not supported. To install Gitea via `brew`:
2525

2626
```
27-
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
2827
brew install gitea
2928
```
3029

docs/content/installation/from-package.fr-fr.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Nous n'avons pas encore publié de paquet pour Windows, nous allons mettre à jo
3030
Actuellement, nous ne supportons que l'installation via `brew` pour macOS. Si vous n'utilisez pas [Homebrew](http://brew.sh/), vous pouvez suivre les [instructions d'installation](installation/from-binary.md) avec le binaire pré-compilé. Pour installer Gitea depuis `brew`, utilisez les commandes suivantes :
3131

3232
```
33-
brew tap go-gitea/gitea
3433
brew install gitea
3534
```
3635

docs/content/installation/from-package.zh-cn.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ menu:
2222
macOS 平台下当前我们仅支持通过 `brew` 来安装。如果你没有安装 [Homebrew](http://brew.sh/),你也可以查看 [从二进制安装](installation/from-binary.md)。在你安装了 `brew` 之后, 你可以执行以下命令:
2323

2424
```
25-
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
2625
brew install gitea
2726
```
2827

docs/content/installation/from-package.zh-tw.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ choco install gitea
3636
目前我們只支援透過 `brew` 來安裝套件。假如您尚未使用 [Homebrew](http://brew.sh/),您就必須參考[執行檔安裝](installation/from-binary.md)方式。透過 `brew` 安裝 Gitea,您只需要執行底下指令:
3737

3838
```
39-
brew tap go-gitea/gitea
4039
brew install gitea
4140
```
4241

docs/content/usage/packages/cargo.en-us.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ Add the following text to the configuration file located in the current users ho
5050
default = "gitea"
5151
5252
[registries.gitea]
53-
index = "https://gitea.example.com/{owner}/_cargo-index.git"
53+
index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
54+
# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
5455
55-
[net]
56-
git-fetch-with-cli = true
56+
# [net]
57+
# git-fetch-with-cli = true
5758
```
5859

5960
| Parameter | Description |
@@ -72,6 +73,12 @@ token = "Bearer {token}"
7273
| --------- | ----------- |
7374
| `token` | Your [personal access token](development/api-usage.md#authentication) |
7475

76+
## Git vs Sparse
77+
78+
Currently, cargo supports two ways for fetching crates in a registry: Git index & sparse index.
79+
Sparse index is the newest method and offers better performance when updating crates compared to git.
80+
Since Rust 1.68, sparse is the default method for crates.io.
81+
7582
## Publish a package
7683

7784
Publish a package by running the following command in your project:

docs/content/usage/packages/cargo.zh-cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ Cargo 将可用软件包的信息存储在一个存储在 git 仓库中的软件
5050
default = "gitea"
5151
5252
[registries.gitea]
53-
index = "https://gitea.example.com/{owner}/_cargo-index.git"
53+
index = "sparse+https://gitea.example.com/api/packages/{owner}/cargo/" # Sparse index
54+
# index = "https://gitea.example.com/{owner}/_cargo-index.git" # Git
5455
5556
[net]
5657
git-fetch-with-cli = true

models/activities/statistic.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package activities
55

66
import (
7+
"context"
8+
79
asymkey_model "code.gitea.io/gitea/models/asymkey"
810
"code.gitea.io/gitea/models/auth"
911
"code.gitea.io/gitea/models/db"
@@ -47,12 +49,12 @@ type IssueByRepositoryCount struct {
4749
}
4850

4951
// GetStatistic returns the database statistics
50-
func GetStatistic() (stats Statistic) {
51-
e := db.GetEngine(db.DefaultContext)
52-
stats.Counter.User = user_model.CountUsers(nil)
52+
func GetStatistic(ctx context.Context) (stats Statistic) {
53+
e := db.GetEngine(ctx)
54+
stats.Counter.User = user_model.CountUsers(ctx, nil)
5355
stats.Counter.Org, _ = organization.CountOrgs(organization.FindOrgOptions{IncludePrivate: true})
5456
stats.Counter.PublicKey, _ = e.Count(new(asymkey_model.PublicKey))
55-
stats.Counter.Repo, _ = repo_model.CountRepositories(db.DefaultContext, repo_model.CountRepositoryOptions{})
57+
stats.Counter.Repo, _ = repo_model.CountRepositories(ctx, repo_model.CountRepositoryOptions{})
5658
stats.Counter.Watch, _ = e.Count(new(repo_model.Watch))
5759
stats.Counter.Star, _ = e.Count(new(repo_model.Star))
5860
stats.Counter.Access, _ = e.Count(new(access_model.Access))

models/asymkey/gpg_key.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func parseSubGPGKey(ownerID int64, primaryID string, pubkey *packet.PublicKey, e
144144
}
145145

146146
// parseGPGKey parse a PrimaryKey entity (primary key + subs keys + self-signature)
147-
func parseGPGKey(ownerID int64, e *openpgp.Entity, verified bool) (*GPGKey, error) {
147+
func parseGPGKey(ctx context.Context, ownerID int64, e *openpgp.Entity, verified bool) (*GPGKey, error) {
148148
pubkey := e.PrimaryKey
149149
expiry := getExpiryTime(e)
150150

@@ -159,7 +159,7 @@ func parseGPGKey(ownerID int64, e *openpgp.Entity, verified bool) (*GPGKey, erro
159159
}
160160

161161
// Check emails
162-
userEmails, err := user_model.GetEmailAddresses(ownerID)
162+
userEmails, err := user_model.GetEmailAddresses(ctx, ownerID)
163163
if err != nil {
164164
return nil, err
165165
}
@@ -251,7 +251,7 @@ func DeleteGPGKey(doer *user_model.User, id int64) (err error) {
251251
return committer.Commit()
252252
}
253253

254-
func checkKeyEmails(email string, keys ...*GPGKey) (bool, string) {
254+
func checkKeyEmails(ctx context.Context, email string, keys ...*GPGKey) (bool, string) {
255255
uid := int64(0)
256256
var userEmails []*user_model.EmailAddress
257257
var user *user_model.User
@@ -263,10 +263,10 @@ func checkKeyEmails(email string, keys ...*GPGKey) (bool, string) {
263263
}
264264
if key.Verified && key.OwnerID != 0 {
265265
if uid != key.OwnerID {
266-
userEmails, _ = user_model.GetEmailAddresses(key.OwnerID)
266+
userEmails, _ = user_model.GetEmailAddresses(ctx, key.OwnerID)
267267
uid = key.OwnerID
268268
user = &user_model.User{ID: uid}
269-
_, _ = user_model.GetUser(user)
269+
_, _ = user_model.GetUser(ctx, user)
270270
}
271271
for _, e := range userEmails {
272272
if e.IsActivated && (email == "" || strings.EqualFold(e.Email, email)) {

models/asymkey/gpg_key_add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func AddGPGKey(ownerID int64, content, token, signature string) ([]*GPGKey, erro
153153

154154
// Get DB session
155155

156-
key, err := parseGPGKey(ownerID, ekey, verified)
156+
key, err := parseGPGKey(ctx, ownerID, ekey, verified)
157157
if err != nil {
158158
return nil, err
159159
}

models/asymkey/gpg_key_commit_verification.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
125125

126126
// If this a SSH signature handle it differently
127127
if strings.HasPrefix(c.Signature.Signature, "-----BEGIN SSH SIGNATURE-----") {
128-
return ParseCommitWithSSHSignature(c, committer)
128+
return ParseCommitWithSSHSignature(ctx, c, committer)
129129
}
130130

131131
// Parsing signature
@@ -150,6 +150,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
150150

151151
// First check if the sig has a keyID and if so just look at that
152152
if commitVerification := hashAndVerifyForKeyID(
153+
ctx,
153154
sig,
154155
c.Signature.Payload,
155156
committer,
@@ -165,7 +166,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
165166

166167
// Now try to associate the signature with the committer, if present
167168
if committer.ID != 0 {
168-
keys, err := ListGPGKeys(db.DefaultContext, committer.ID, db.ListOptions{})
169+
keys, err := ListGPGKeys(ctx, committer.ID, db.ListOptions{})
169170
if err != nil { // Skipping failed to get gpg keys of user
170171
log.Error("ListGPGKeys: %v", err)
171172
return &CommitVerification{
@@ -175,7 +176,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
175176
}
176177
}
177178

178-
committerEmailAddresses, _ := user_model.GetEmailAddresses(committer.ID)
179+
committerEmailAddresses, _ := user_model.GetEmailAddresses(ctx, committer.ID)
179180
activated := false
180181
for _, e := range committerEmailAddresses {
181182
if e.IsActivated && strings.EqualFold(e.Email, c.Committer.Email) {
@@ -222,7 +223,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
222223
}
223224
if err := gpgSettings.LoadPublicKeyContent(); err != nil {
224225
log.Error("Error getting default signing key: %s %v", gpgSettings.KeyID, err)
225-
} else if commitVerification := verifyWithGPGSettings(&gpgSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
226+
} else if commitVerification := verifyWithGPGSettings(ctx, &gpgSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
226227
if commitVerification.Reason == BadSignature {
227228
defaultReason = BadSignature
228229
} else {
@@ -237,7 +238,7 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
237238
} else if defaultGPGSettings == nil {
238239
log.Warn("Unable to get defaultGPGSettings for unattached commit: %s", c.ID.String())
239240
} else if defaultGPGSettings.Sign {
240-
if commitVerification := verifyWithGPGSettings(defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
241+
if commitVerification := verifyWithGPGSettings(ctx, defaultGPGSettings, sig, c.Signature.Payload, committer, keyID); commitVerification != nil {
241242
if commitVerification.Reason == BadSignature {
242243
defaultReason = BadSignature
243244
} else {
@@ -257,9 +258,9 @@ func ParseCommitWithSignature(ctx context.Context, c *git.Commit) *CommitVerific
257258
}
258259
}
259260

260-
func verifyWithGPGSettings(gpgSettings *git.GPGSettings, sig *packet.Signature, payload string, committer *user_model.User, keyID string) *CommitVerification {
261+
func verifyWithGPGSettings(ctx context.Context, gpgSettings *git.GPGSettings, sig *packet.Signature, payload string, committer *user_model.User, keyID string) *CommitVerification {
261262
// First try to find the key in the db
262-
if commitVerification := hashAndVerifyForKeyID(sig, payload, committer, gpgSettings.KeyID, gpgSettings.Name, gpgSettings.Email); commitVerification != nil {
263+
if commitVerification := hashAndVerifyForKeyID(ctx, sig, payload, committer, gpgSettings.KeyID, gpgSettings.Name, gpgSettings.Email); commitVerification != nil {
263264
return commitVerification
264265
}
265266

@@ -387,7 +388,7 @@ func hashAndVerifyWithSubKeysCommitVerification(sig *packet.Signature, payload s
387388
return nil
388389
}
389390

390-
func hashAndVerifyForKeyID(sig *packet.Signature, payload string, committer *user_model.User, keyID, name, email string) *CommitVerification {
391+
func hashAndVerifyForKeyID(ctx context.Context, sig *packet.Signature, payload string, committer *user_model.User, keyID, name, email string) *CommitVerification {
391392
if keyID == "" {
392393
return nil
393394
}
@@ -417,7 +418,7 @@ func hashAndVerifyForKeyID(sig *packet.Signature, payload string, committer *use
417418
}
418419
}
419420

420-
activated, email := checkKeyEmails(email, append([]*GPGKey{key}, primaryKeys...)...)
421+
activated, email := checkKeyEmails(ctx, email, append([]*GPGKey{key}, primaryKeys...)...)
421422
if !activated {
422423
continue
423424
}
@@ -427,7 +428,7 @@ func hashAndVerifyForKeyID(sig *packet.Signature, payload string, committer *use
427428
Email: email,
428429
}
429430
if key.OwnerID != 0 {
430-
owner, err := user_model.GetUserByID(db.DefaultContext, key.OwnerID)
431+
owner, err := user_model.GetUserByID(ctx, key.OwnerID)
431432
if err == nil {
432433
signer = owner
433434
} else if !user_model.IsErrUserNotExist(err) {

models/asymkey/ssh_key_commit_verification.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package asymkey
55

66
import (
77
"bytes"
8+
"context"
89
"fmt"
910
"strings"
1011

@@ -17,7 +18,7 @@ import (
1718
)
1819

1920
// ParseCommitWithSSHSignature check if signature is good against keystore.
20-
func ParseCommitWithSSHSignature(c *git.Commit, committer *user_model.User) *CommitVerification {
21+
func ParseCommitWithSSHSignature(ctx context.Context, c *git.Commit, committer *user_model.User) *CommitVerification {
2122
// Now try to associate the signature with the committer, if present
2223
if committer.ID != 0 {
2324
keys, err := ListPublicKeys(committer.ID, db.ListOptions{})
@@ -30,7 +31,7 @@ func ParseCommitWithSSHSignature(c *git.Commit, committer *user_model.User) *Com
3031
}
3132
}
3233

33-
committerEmailAddresses, err := user_model.GetEmailAddresses(committer.ID)
34+
committerEmailAddresses, err := user_model.GetEmailAddresses(ctx, committer.ID)
3435
if err != nil {
3536
log.Error("GetEmailAddresses: %v", err)
3637
}

0 commit comments

Comments
 (0)