Skip to content

Commit ae5616b

Browse files
authored
Merge branch 'main' into highlight-patch
2 parents 8b21e09 + 6d2a333 commit ae5616b

Some content is hidden

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

72 files changed

+577
-194
lines changed

.drone.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ steps:
414414
settings:
415415
author_email: "[email protected]"
416416
author_name: GiteaBot
417+
branch: main
417418
commit: true
418419
commit_message: "[skip ci] Updated translations via Crowdin"
419420
remote: "[email protected]:go-gitea/gitea.git"
@@ -461,6 +462,7 @@ steps:
461462
settings:
462463
author_email: "[email protected]"
463464
author_name: GiteaBot
465+
branch: main
464466
commit: true
465467
commit_message: "[skip ci] Updated licenses and gitignores "
466468
remote: "[email protected]:go-gitea/gitea.git"
@@ -528,7 +530,7 @@ steps:
528530
image: plugins/s3:1
529531
settings:
530532
acl: public-read
531-
bucket: releases
533+
bucket: gitea-artifacts
532534
endpoint: https://storage.gitea.io
533535
path_style: true
534536
source: "dist/release/*"
@@ -549,7 +551,7 @@ steps:
549551
image: plugins/s3:1
550552
settings:
551553
acl: public-read
552-
bucket: releases
554+
bucket: gitea-artifacts
553555
endpoint: https://storage.gitea.io
554556
path_style: true
555557
source: "dist/release/*"
@@ -624,7 +626,7 @@ steps:
624626
image: plugins/s3:1
625627
settings:
626628
acl: public-read
627-
bucket: releases
629+
bucket: gitea-artifacts
628630
endpoint: https://storage.gitea.io
629631
path_style: true
630632
source: "dist/release/*"

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ NOTES:
101101
1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
102102
2. If you have found a vulnerability in the project, please write privately to **[email protected]**. Thanks!
103103

104+
## Translating
105+
106+
Translations are done through Crowdin. If you want to translate to a new language ask one of the managers in the Crowdin project to add a new language there.
107+
108+
You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope fo fill it as questions pop up.
109+
110+
https://docs.gitea.io/en-us/translation-guidelines/
111+
112+
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
113+
104114
## Further information
105115

106116
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).

README_ZH.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ Gitea 的首要目标是创建一个极易安装,运行非常快速,安装
7171

7272
Fork -> Patch -> Push -> Pull Request
7373

74+
## 翻译
75+
76+
多语言翻译是基于Crowdin进行的.
77+
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
78+
7479
## 作者
7580

7681
* [Maintainers](https://github.com/orgs/go-gitea/people)

cmd/restore_repo.go

Lines changed: 11 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
package cmd
66

77
import (
8-
"context"
9-
"strings"
8+
"errors"
9+
"net/http"
1010

1111
"code.gitea.io/gitea/modules/log"
12-
"code.gitea.io/gitea/modules/migrations"
13-
"code.gitea.io/gitea/modules/migrations/base"
12+
"code.gitea.io/gitea/modules/private"
1413
"code.gitea.io/gitea/modules/setting"
15-
"code.gitea.io/gitea/modules/storage"
16-
pull_service "code.gitea.io/gitea/services/pull"
1714

1815
"github.com/urfave/cli"
1916
)
@@ -50,70 +47,18 @@ wiki, issues, labels, releases, release_assets, milestones, pull_requests, comme
5047
}
5148

5249
func runRestoreRepository(ctx *cli.Context) error {
53-
if err := initDB(); err != nil {
54-
return err
55-
}
56-
57-
log.Trace("AppPath: %s", setting.AppPath)
58-
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
59-
log.Trace("Custom path: %s", setting.CustomPath)
60-
log.Trace("Log path: %s", setting.LogRootPath)
61-
setting.InitDBConfig()
62-
63-
if err := storage.Init(); err != nil {
64-
return err
65-
}
66-
67-
if err := pull_service.Init(); err != nil {
68-
return err
69-
}
70-
71-
var opts = base.MigrateOptions{
72-
RepoName: ctx.String("repo_name"),
73-
}
74-
75-
if len(ctx.String("units")) == 0 {
76-
opts.Wiki = true
77-
opts.Issues = true
78-
opts.Milestones = true
79-
opts.Labels = true
80-
opts.Releases = true
81-
opts.Comments = true
82-
opts.PullRequests = true
83-
opts.ReleaseAssets = true
84-
} else {
85-
units := strings.Split(ctx.String("units"), ",")
86-
for _, unit := range units {
87-
switch strings.ToLower(unit) {
88-
case "wiki":
89-
opts.Wiki = true
90-
case "issues":
91-
opts.Issues = true
92-
case "milestones":
93-
opts.Milestones = true
94-
case "labels":
95-
opts.Labels = true
96-
case "releases":
97-
opts.Releases = true
98-
case "release_assets":
99-
opts.ReleaseAssets = true
100-
case "comments":
101-
opts.Comments = true
102-
case "pull_requests":
103-
opts.PullRequests = true
104-
}
105-
}
106-
}
50+
setting.NewContext()
10751

108-
if err := migrations.RestoreRepository(
109-
context.Background(),
52+
statusCode, errStr := private.RestoreRepo(
11053
ctx.String("repo_dir"),
11154
ctx.String("owner_name"),
11255
ctx.String("repo_name"),
113-
); err != nil {
114-
log.Fatal("Failed to restore repository: %v", err)
115-
return err
56+
ctx.StringSlice("units"),
57+
)
58+
if statusCode == http.StatusOK {
59+
return nil
11660
}
11761

118-
return nil
62+
log.Fatal("Failed to restore repository: %v", errStr)
63+
return errors.New(errStr)
11964
}

cmd/web_letsencrypt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cmd
66

77
import (
88
"net/http"
9+
"strconv"
910
"strings"
1011

1112
"code.gitea.io/gitea/modules/log"
@@ -22,6 +23,11 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
2223
// TODO: these are placeholders until we add options for each in settings with appropriate warning
2324
enableHTTPChallenge := true
2425
enableTLSALPNChallenge := true
26+
altHTTPPort := 0
27+
28+
if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
29+
altHTTPPort = p
30+
}
2531

2632
magic := certmagic.NewDefault()
2733
magic.Storage = &certmagic.FileStorage{Path: directory}
@@ -30,6 +36,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
3036
Agreed: setting.LetsEncryptTOS,
3137
DisableHTTPChallenge: !enableHTTPChallenge,
3238
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
39+
ListenHost: listenAddr,
40+
AltHTTPPort: altHTTPPort,
3341
})
3442

3543
magic.Issuers = []certmagic.Issuer{myACME}

custom/conf/app.example.ini

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,15 @@ PATH =
903903
;; - approved: only sign when merging an approved pr to a protected branch
904904
;MERGES = pubkey, twofa, basesigned, commitssigned
905905

906+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
907+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
908+
;[repository.mimetype_mapping]
909+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
910+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
911+
;;
912+
;; Custom MIME type mapping for downloadable files
913+
;.apk=application/vnd.android.package-archive
914+
906915
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
907916
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
908917
;[project]
@@ -912,7 +921,6 @@ PATH =
912921
;PROJECT_BOARD_BASIC_KANBAN_TYPE = To Do, In Progress, Done
913922
;PROJECT_BOARD_BUG_TRIAGE_TYPE = Needs Triage, High Priority, Low Priority, Closed
914923

915-
916924
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
917925
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
918926
;[cors]
@@ -1591,6 +1599,11 @@ PATH =
15911599
;ENABLED = false
15921600
;; Setting this to true will run all enabled cron tasks when Gitea starts.
15931601
;RUN_AT_START = false
1602+
;;
1603+
;; Note: ``SCHEDULE`` accept formats
1604+
;; - Full crontab specs, e.g. "* * * * * ?"
1605+
;; - Descriptors, e.g. "@midnight", "@every 1h30m"
1606+
;; See more: https://pkg.go.dev/github.com/gogs/[email protected]
15941607

15951608
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15961609
;; Basic cron tasks - enabled by default

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
143143

144144
- `LOCAL_COPY_PATH`: **tmp/local-repo**: Path for temporary local repository copies. Defaults to `tmp/local-repo`
145145

146+
## Repository - MIME type mapping (`repository.mimetype_mapping`)
147+
148+
Configuration for set the expected MIME type based on file extensions of downloadable files. Configuration presents in key-value pairs and file extensions starts with leading `.`.
149+
150+
The following configuration set `Content-Type: application/vnd.android.package-archive` header when downloading files with `.apk` file extension.
151+
```ini
152+
.apk=application/vnd.android.package-archive
153+
```
154+
146155
## CORS (`cors`)
147156

148157
- `ENABLED`: **false**: enable cors headers (disabled by default)
@@ -704,6 +713,11 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
704713
- `RUN_AT_START`: **false**: Run cron tasks at application start-up.
705714
- `NO_SUCCESS_NOTICE`: **false**: Set to true to switch off success notices.
706715

716+
- `SCHEDULE` accept formats
717+
- Full crontab specs, e.g. `* * * * * ?`
718+
- Descriptors, e.g. `@midnight`, `@every 1h30m` ...
719+
- See more: [cron decument](https://pkg.go.dev/github.com/gogs/[email protected])
720+
707721
### Basic cron tasks - enabled by default
708722

709723
#### Cron - Cleanup old repository archives (`cron.archive_cleanup`)

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ test01.xls: application/vnd.ms-excel; charset=binary
245245

246246
- `ENABLED`: 是否在后台运行定期任务。
247247
- `RUN_AT_START`: 是否启动时自动运行。
248+
- `SCHEDULE` 所接受的格式
249+
- 完整 crontab 控制, 例如 `* * * * * ?`
250+
- 描述符, 例如 `@midnight`, `@every 1h30m` ...
251+
- 更多细节参见 [cron api文档](https://pkg.go.dev/github.com/gogs/[email protected])
252+
248253

249254
### Cron - Update Mirrors (`cron.update_mirrors`)
250255

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ require (
105105
github.com/unknwon/com v1.0.1
106106
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44
107107
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
108-
github.com/unrolled/render v1.1.0
108+
github.com/unrolled/render v1.1.1
109109
github.com/urfave/cli v1.22.5
110110
github.com/willf/bitset v1.1.11 // indirect
111111
github.com/xanzy/go-gitlab v0.48.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 h1:7bSo/vjZKVYUoZfxpY
10991099
github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
11001100
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
11011101
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
1102-
github.com/unrolled/render v1.1.0 h1:gvpR9hHxTt6DcGqRYuVVFcfd8rtK+nyEPUJN06KB57Q=
1103-
github.com/unrolled/render v1.1.0/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
1102+
github.com/unrolled/render v1.1.1 h1:FpzNzkvlJQIlVdVaqeVBGWiCS8gpbmjtrKpDmCn6p64=
1103+
github.com/unrolled/render v1.1.1/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM=
11041104
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
11051105
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
11061106
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=

models/avatar_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ func TestHashEmail(t *testing.T) {
4040
}
4141

4242
func TestSizedAvatarLink(t *testing.T) {
43+
setting.AppSubURL = "/testsuburl"
44+
4345
disableGravatar()
44-
assert.Equal(t, "/suburl/assets/img/avatar_default.png",
46+
assert.Equal(t, "/testsuburl/assets/img/avatar_default.png",
4547
SizedAvatarLink("[email protected]", 100))
4648

4749
enableGravatar(t)

models/gpg_key_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ MkM/fdpyc2hY7Dl/+qFmN5MG5yGmMpQcX+RNNR222ibNC1D3wg==
103103
=i9b7
104104
-----END PGP PUBLIC KEY BLOCK-----`
105105
keys, err := checkArmoredGPGKeyString(testGPGArmor)
106+
if !assert.NotEmpty(t, keys) {
107+
return
108+
}
106109
ekey := keys[0]
107110
assert.NoError(t, err, "Could not parse a valid GPG armored key", ekey)
108111

@@ -189,6 +192,10 @@ Unknown GPG key with good email
189192
}
190193

191194
func TestCheckGPGUserEmail(t *testing.T) {
195+
assert.NoError(t, PrepareTestDatabase())
196+
197+
_ = AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
198+
192199
testEmailWithUpperCaseLetters := `-----BEGIN PGP PUBLIC KEY BLOCK-----
193200
Version: GnuPG v1
194201
@@ -222,9 +229,11 @@ Q0KHb+QcycSgbDx0ZAvdIacuKvBBcbxrsmFUI4LR+oIup0G9gUc0roPvr014jYQL
222229

223230
keys, err := AddGPGKey(1, testEmailWithUpperCaseLetters)
224231
assert.NoError(t, err)
225-
key := keys[0]
226-
if assert.Len(t, key.Emails, 1) {
227-
assert.Equal(t, "[email protected]", key.Emails[0].Email)
232+
if assert.NotEmpty(t, keys) {
233+
key := keys[0]
234+
if assert.Len(t, key.Emails, 1) {
235+
assert.Equal(t, "[email protected]", key.Emails[0].Email)
236+
}
228237
}
229238
}
230239

@@ -374,7 +383,9 @@ epiDVQ==
374383
`
375384
keys, err := checkArmoredGPGKeyString(testIssue6599)
376385
assert.NoError(t, err)
377-
ekey := keys[0]
378-
expire := getExpiryTime(ekey)
379-
assert.Equal(t, time.Unix(1586105389, 0), expire)
386+
if assert.NotEmpty(t, keys) {
387+
ekey := keys[0]
388+
expire := getExpiryTime(ekey)
389+
assert.Equal(t, time.Unix(1586105389, 0), expire)
390+
}
380391
}

models/issue_assignees_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func TestUpdateAssignee(t *testing.T) {
6161
}
6262

6363
func TestMakeIDsFromAPIAssigneesToAdd(t *testing.T) {
64+
assert.NoError(t, PrepareTestDatabase())
65+
66+
_ = AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
67+
_ = AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
68+
6469
IDs, err := MakeIDsFromAPIAssigneesToAdd("", []string{""})
6570
assert.NoError(t, err)
6671
assert.Equal(t, []int64{}, IDs)

models/issue_xref.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ func CommentTypeIsRef(t CommentType) bool {
290290

291291
// RefCommentHTMLURL returns the HTML URL for the comment that created this reference
292292
func (comment *Comment) RefCommentHTMLURL() string {
293+
if comment.RefCommentID == 0 {
294+
return ""
295+
}
293296
if err := comment.LoadRefComment(); err != nil { // Silently dropping errors :unamused:
294297
log.Error("LoadRefComment(%d): %v", comment.RefCommentID, err)
295298
return ""

0 commit comments

Comments
 (0)