Skip to content

Commit b272dc8

Browse files
committed
Merge remote-tracking branch 'origin/main' into disable-basic-authentication-2
2 parents 6ec5e60 + ec2addc commit b272dc8

Some content is hidden

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

57 files changed

+285
-60
lines changed

.drone.yml

Lines changed: 2 additions & 0 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"

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)

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

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 ""

models/migrations/v156.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
8888
repo = new(Repository)
8989
has, err := sess.ID(release.RepoID).Get(repo)
9090
if err != nil {
91-
log.Error("Error whilst loading repository[%d] for release[%d] with tag name %s", release.RepoID, release.ID, release.TagName)
91+
log.Error("Error whilst loading repository[%d] for release[%d] with tag name %s. Error: %v", release.RepoID, release.ID, release.TagName, err)
9292
return err
9393
} else if !has {
9494
log.Warn("Release[%d] is orphaned and refers to non-existing repository %d", release.ID, release.RepoID)
@@ -105,32 +105,50 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
105105
}
106106

107107
if _, err := sess.ID(release.RepoID).Get(repo); err != nil {
108-
log.Error("Error whilst loading repository[%d] for release[%d] with tag name %s", release.RepoID, release.ID, release.TagName)
108+
log.Error("Error whilst loading repository[%d] for release[%d] with tag name %s. Error: %v", release.RepoID, release.ID, release.TagName, err)
109109
return err
110110
}
111111
}
112112
gitRepo, err = git.OpenRepository(repoPath(repo.OwnerName, repo.Name))
113113
if err != nil {
114-
log.Error("Error whilst opening git repo for %-v", repo)
114+
log.Error("Error whilst opening git repo for [%d]%s/%s. Error: %v", repo.ID, repo.OwnerName, repo.Name, err)
115115
return err
116116
}
117117
}
118118

119119
commit, err := gitRepo.GetTagCommit(release.TagName)
120120
if err != nil {
121121
if git.IsErrNotExist(err) {
122-
log.Warn("Unable to find commit %s for Tag: %s in %-v. Cannot update publisher ID.", err.(git.ErrNotExist).ID, release.TagName, repo)
122+
log.Warn("Unable to find commit %s for Tag: %s in [%d]%s/%s. Cannot update publisher ID.", err.(git.ErrNotExist).ID, release.TagName, repo.ID, repo.OwnerName, repo.Name)
123123
continue
124124
}
125-
log.Error("Error whilst getting commit for Tag: %s in %-v.", release.TagName, repo)
125+
log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v", release.TagName, repo.ID, repo.OwnerName, repo.Name, err)
126126
return fmt.Errorf("GetTagCommit: %v", err)
127127
}
128128

129+
if commit.Author.Email == "" {
130+
log.Warn("Tag: %s in Repo[%d]%s/%s does not have a tagger.", release.TagName, repo.ID, repo.OwnerName, repo.Name)
131+
commit, err = gitRepo.GetCommit(commit.ID.String())
132+
if err != nil {
133+
if git.IsErrNotExist(err) {
134+
log.Warn("Unable to find commit %s for Tag: %s in [%d]%s/%s. Cannot update publisher ID.", err.(git.ErrNotExist).ID, release.TagName, repo.ID, repo.OwnerName, repo.Name)
135+
continue
136+
}
137+
log.Error("Error whilst getting commit for Tag: %s in [%d]%s/%s. Error: %v", release.TagName, repo.ID, repo.OwnerName, repo.Name, err)
138+
return fmt.Errorf("GetCommit: %v", err)
139+
}
140+
}
141+
142+
if commit.Author.Email == "" {
143+
log.Warn("Tag: %s in Repo[%d]%s/%s does not have a Tagger and its underlying commit does not have an Author either!", release.TagName, repo.ID, repo.OwnerName, repo.Name)
144+
continue
145+
}
146+
129147
if user == nil || !strings.EqualFold(user.Email, commit.Author.Email) {
130148
user = new(User)
131149
_, err = sess.Where("email=?", commit.Author.Email).Get(user)
132150
if err != nil {
133-
log.Error("Error whilst getting commit author by email: %s for Tag: %s in %-v.", commit.Author.Email, release.TagName, repo)
151+
log.Error("Error whilst getting commit author by email: %s for Tag: %s in [%d]%s/%s. Error: %v", commit.Author.Email, release.TagName, repo.ID, repo.OwnerName, repo.Name, err)
134152
return err
135153
}
136154

@@ -143,7 +161,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
143161

144162
release.PublisherID = user.ID
145163
if _, err := sess.ID(release.ID).Cols("publisher_id").Update(release); err != nil {
146-
log.Error("Error whilst updating publisher[%d] for release[%d] with tag name %s", release.PublisherID, release.ID, release.TagName)
164+
log.Error("Error whilst updating publisher[%d] for release[%d] with tag name %s. Error: %v", release.PublisherID, release.ID, release.TagName, err)
147165
return err
148166
}
149167
}

models/user_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ func TestCreateUser_Issue5882(t *testing.T) {
368368
}
369369

370370
func TestGetUserIDsByNames(t *testing.T) {
371+
assert.NoError(t, PrepareTestDatabase())
372+
371373
// ignore non existing
372374
IDs, err := GetUserIDsByNames([]string{"user1", "user2", "none_existing_user"}, true)
373375
assert.NoError(t, err)
@@ -380,6 +382,8 @@ func TestGetUserIDsByNames(t *testing.T) {
380382
}
381383

382384
func TestGetMaileableUsersByIDs(t *testing.T) {
385+
assert.NoError(t, PrepareTestDatabase())
386+
383387
results, err := GetMaileableUsersByIDs([]int64{1, 4}, false)
384388
assert.NoError(t, err)
385389
assert.Equal(t, 1, len(results))

modules/convert/user.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func toUser(user *models.User, signed, authed bool) *api.User {
5858
result.IsAdmin = user.IsAdmin
5959
result.LastLogin = user.LastLoginUnix.AsTime()
6060
result.Language = user.Language
61+
result.IsActive = user.IsActive
62+
result.ProhibitLogin = user.ProhibitLogin
6163
}
6264
return result
6365
}

modules/convert/user_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/models"
11+
1112
"github.com/stretchr/testify/assert"
1213
)
1314

1415
func TestUser_ToUser(t *testing.T) {
16+
assert.NoError(t, models.PrepareTestDatabase())
1517

1618
user1 := models.AssertExistsAndLoadBean(t, &models.User{ID: 1, IsAdmin: true}).(*models.User)
1719

modules/doctor/dbversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func checkDBVersion(logger log.Logger, autofix bool) error {
2323

2424
err = models.NewEngine(context.Background(), migrations.Migrate)
2525
if err != nil {
26-
logger.Critical("Error: %v during migration")
26+
logger.Critical("Error: %v during migration", err)
2727
}
2828
return err
2929
}

modules/git/commit_reader.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import (
1717
// If used as part of a cat-file --batch stream you need to limit the reader to the correct size
1818
func CommitFromReader(gitRepo *Repository, sha SHA1, reader io.Reader) (*Commit, error) {
1919
commit := &Commit{
20-
ID: sha,
20+
ID: sha,
21+
Author: &Signature{},
22+
Committer: &Signature{},
2123
}
2224

2325
payloadSB := new(strings.Builder)

modules/git/tag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func (tag *Tag) Commit() (*Commit, error) {
3535
// \n\n separate headers from message
3636
func parseTagData(data []byte) (*Tag, error) {
3737
tag := new(Tag)
38+
tag.Tagger = &Signature{}
3839
// we now have the contents of the commit object. Let's investigate...
3940
nextline := 0
4041
l:

modules/queue/manager.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,20 @@ func (m *Manager) FlushAll(baseCtx context.Context, timeout time.Duration) error
198198
wg.Done()
199199
}(mq)
200200
} else {
201-
log.Debug("Queue: %s is non-empty but is not flushable - adding 100 millisecond wait", mq.Name)
202-
go func() {
203-
<-time.After(100 * time.Millisecond)
204-
wg.Done()
205-
}()
201+
log.Debug("Queue: %s is non-empty but is not flushable", mq.Name)
202+
wg.Done()
206203
}
207-
208204
}
209205
if allEmpty {
206+
log.Debug("All queues are empty")
210207
break
211208
}
209+
// Ensure there are always at least 100ms between loops but not more if we've actually been doing some flushign
210+
// but don't delay cancellation here.
211+
select {
212+
case <-ctx.Done():
213+
case <-time.After(100 * time.Millisecond):
214+
}
212215
wg.Wait()
213216
}
214217
return nil

0 commit comments

Comments
 (0)