Skip to content

Commit 0e87746

Browse files
committed
Merge remote-tracking branch 'main/release/v1.16' into codeberg-1.16
2 parents 163e2ed + acd6480 commit 0e87746

File tree

13 files changed

+145
-53
lines changed

13 files changed

+145
-53
lines changed

CHANGELOG.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,42 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7-
## [1.16.5](https://github.com/go-gitea/gitea/releases/tag/1.16.5) - 2022-03-23
7+
## [1.16.6](https://github.com/go-gitea/gitea/releases/tag/v1.16.6) - 2022-04-20
8+
9+
* ENHANCEMENTS
10+
* Only request write when necessary (#18657) (#19422)
11+
* Disable service worker by default (#18914) (#19342)
12+
* BUGFIXES
13+
* When dumping trim the standard suffices instead of a random suffix (#19440) (#19447)
14+
* Fix DELETE request for non-existent public key (#19443) (#19444)
15+
* Don't panic on ErrEmailInvalid (#19441) (#19442)
16+
* Add uploadpack.allowAnySHA1InWant to allow --filter=blob:none with older git clients (#19430) (#19438)
17+
* Warn on SSH connection for incorrect configuration (#19317) (#19437)
18+
* Search Issues via API, dont show 500 if filter result in empty list (#19244) (#19436)
19+
* When updating mirror repo intervals by API reschedule next update too (#19429) (#19433)
20+
* Fix nil error when some pages are rendered outside request context (#19427) (#19428)
21+
* Fix double blob-hunk on diff page (#19404) (#19405)
22+
* Don't allow merging PR's which are being conflict checked (#19357) (#19358)
23+
* Fix middleware function's placements (#19377) (#19378)
24+
* Fix invalid CSRF token bug, make sure CSRF tokens can be up-to-date (#19338)
25+
* Restore user autoregistration with email addresses (#19261) (#19312)
26+
* Move checks for pulls before merge into own function (#19271) (#19277)
27+
* Granular webhook events in editHook (#19251) (#19257)
28+
* Only send webhook events to active system webhooks and only deliver to active hooks (#19234) (#19248)
29+
* Use full output of git show-ref --tags to get tags for PushUpdateAddTag (#19235) (#19236)
30+
* Touch mirrors on even on fail to update (#19217) (#19233)
31+
* Hide sensitive content on admin panel progress monitor (#19218 & #19226) (#19231)
32+
* Fix clone url JS error for the empty repo page (#19209)
33+
* Bump goldmark to v1.4.11 (#19201) (#19203)
34+
* TESTING
35+
* Prevent intermittent failures in RepoIndexerTest (#19225 #19229) (#19228)
36+
* BUILD
37+
* Revert the minimal golang version requirement from 1.17 to 1.16 and add a warning in Makefile (#19319)
38+
* MISC
39+
* Performance improvement for add team user when org has more than 1000 repositories (#19227) (#19289)
40+
* Check go and nodejs version by go.mod and package.json (#19197) (#19254)
41+
42+
## [1.16.5](https://github.com/go-gitea/gitea/releases/tag/v1.16.5) - 2022-03-23
843

944
* BREAKING
1045
* Bump to build with go1.18 (#19120 et al) (#19127)

cmd/dump.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (o outputType) String() string {
8686
}
8787

8888
var outputTypeEnum = &outputType{
89-
Enum: []string{"zip", "rar", "tar", "sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
89+
Enum: []string{"zip", "tar", "tar.sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4"},
9090
Default: "zip",
9191
}
9292

@@ -160,7 +160,12 @@ func runDump(ctx *cli.Context) error {
160160
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
161161
}
162162
} else {
163-
fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
163+
for _, suffix := range outputTypeEnum.Enum {
164+
if strings.HasSuffix(fileName, "."+suffix) {
165+
fileName = strings.TrimSuffix(fileName, "."+suffix)
166+
break
167+
}
168+
}
164169
fileName += "." + outType
165170
}
166171
setting.LoadFromExisting()

cmd/serv.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ func runServ(c *cli.Context) error {
297297
gitcmd = exec.CommandContext(ctx, verb, repoPath)
298298
}
299299

300+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
301+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
302+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
303+
if os.IsNotExist(err) {
304+
return fail("Incorrect configuration.",
305+
"Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.")
306+
}
307+
}
308+
300309
gitcmd.Dir = setting.RepoRootPath
301310
gitcmd.Stdout = os.Stdout
302311
gitcmd.Stdin = os.Stdin

integrations/api_user_email_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ func TestAPIAddEmail(t *testing.T) {
6969
Primary: false,
7070
},
7171
}, emails)
72+
73+
opts = api.CreateEmailOption{
74+
Emails: []string{"notAEmail"},
75+
}
76+
req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
77+
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
7278
}
7379

7480
func TestAPIDeleteEmail(t *testing.T) {

modules/git/git.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func SetExecutablePath(path string) error {
112112

113113
// VersionInfo returns git version information
114114
func VersionInfo() string {
115-
var format = "Git Version: %s"
116-
var args = []interface{}{gitVersion.Original()}
115+
format := "Git Version: %s"
116+
args := []interface{}{gitVersion.Original()}
117117
// Since git wire protocol has been released from git v2.18
118118
if setting.Git.EnableAutoGitWireProtocol && CheckGitVersionAtLeast("2.18") == nil {
119119
format += ", Wire Protocol %s Enabled"
@@ -148,7 +148,7 @@ func Init(ctx context.Context) error {
148148

149149
// By default partial clones are disabled, enable them from git v2.22
150150
if !setting.Git.DisablePartialClone && CheckGitVersionAtLeast("2.22") == nil {
151-
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "uploadpack.allowfilter=true")
151+
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "uploadpack.allowfilter=true", "-c", "uploadpack.allowAnySHA1InWant=true")
152152
}
153153

154154
// Save current git version on init to gitVersion otherwise it would require an RWMutex

modules/setting/setting.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package setting
88
import (
99
"encoding/base64"
1010
"fmt"
11-
"io"
1211
"math"
1312
"net"
1413
"net/url"
@@ -1095,28 +1094,22 @@ func loadInternalToken(sec *ini.Section) string {
10951094
}
10961095
switch tempURI.Scheme {
10971096
case "file":
1098-
fp, err := os.OpenFile(tempURI.RequestURI(), os.O_RDWR, 0o600)
1099-
if err != nil {
1097+
buf, err := os.ReadFile(tempURI.RequestURI())
1098+
if err != nil && !os.IsNotExist(err) {
11001099
log.Fatal("Failed to open InternalTokenURI (%s): %v", uri, err)
11011100
}
1102-
defer fp.Close()
1103-
1104-
buf, err := io.ReadAll(fp)
1105-
if err != nil {
1106-
log.Fatal("Failed to read InternalTokenURI (%s): %v", uri, err)
1107-
}
11081101
// No token in the file, generate one and store it.
11091102
if len(buf) == 0 {
11101103
token, err := generate.NewInternalToken()
11111104
if err != nil {
11121105
log.Fatal("Error generate internal token: %v", err)
11131106
}
1114-
if _, err := io.WriteString(fp, token); err != nil {
1107+
err = os.WriteFile(tempURI.RequestURI(), []byte(token), 0o600)
1108+
if err != nil {
11151109
log.Fatal("Error writing to InternalTokenURI (%s): %v", uri, err)
11161110
}
11171111
return token
11181112
}
1119-
11201113
return strings.TrimSpace(string(buf))
11211114
default:
11221115
log.Fatal("Unsupported URI-Scheme %q (INTERNAL_TOKEN_URI = %q)", tempURI.Scheme, uri)

modules/structs/repo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ type EditRepoOption struct {
183183
Archived *bool `json:"archived,omitempty"`
184184
// set to a string like `8h30m0s` to set the mirror interval time
185185
MirrorInterval *string `json:"mirror_interval,omitempty"`
186+
// enable prune - remove obsolete remote-tracking references
187+
EnablePrune *bool `json:"enable_prune,omitempty"`
186188
}
187189

188190
// GenerateRepoOption options when creating repository using a template

routers/api/v1/repo/repo.go

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func Edit(ctx *context.APIContext) {
624624
}
625625

626626
if opts.MirrorInterval != nil {
627-
if err := updateMirrorInterval(ctx, opts); err != nil {
627+
if err := updateMirror(ctx, opts); err != nil {
628628
return
629629
}
630630
}
@@ -949,37 +949,67 @@ func updateRepoArchivedState(ctx *context.APIContext, opts api.EditRepoOption) e
949949
return nil
950950
}
951951

952-
// updateMirrorInterval updates the repo's mirror Interval
953-
func updateMirrorInterval(ctx *context.APIContext, opts api.EditRepoOption) error {
952+
// updateMirror updates a repo's mirror Interval and EnablePrune
953+
func updateMirror(ctx *context.APIContext, opts api.EditRepoOption) error {
954954
repo := ctx.Repo.Repository
955955

956+
// only update mirror if interval or enable prune are provided
957+
if opts.MirrorInterval == nil && opts.EnablePrune == nil {
958+
return nil
959+
}
960+
961+
// these values only make sense if the repo is a mirror
962+
if !repo.IsMirror {
963+
err := fmt.Errorf("repo is not a mirror, can not change mirror interval")
964+
ctx.Error(http.StatusUnprocessableEntity, err.Error(), err)
965+
return err
966+
}
967+
968+
// get the mirror from the repo
969+
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
970+
if err != nil {
971+
log.Error("Failed to get mirror: %s", err)
972+
ctx.Error(http.StatusInternalServerError, "MirrorInterval", err)
973+
return err
974+
}
975+
976+
// update MirrorInterval
956977
if opts.MirrorInterval != nil {
957-
if !repo.IsMirror {
958-
err := fmt.Errorf("repo is not a mirror, can not change mirror interval")
959-
ctx.Error(http.StatusUnprocessableEntity, err.Error(), err)
960-
return err
961-
}
962-
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
978+
979+
// MirrorInterval should be a duration
980+
interval, err := time.ParseDuration(*opts.MirrorInterval)
963981
if err != nil {
964-
log.Error("Failed to get mirror: %s", err)
965-
ctx.Error(http.StatusInternalServerError, "MirrorInterval", err)
982+
log.Error("Wrong format for MirrorInternal Sent: %s", err)
983+
ctx.Error(http.StatusUnprocessableEntity, "MirrorInterval", err)
966984
return err
967985
}
968-
if interval, err := time.ParseDuration(*opts.MirrorInterval); err == nil {
969-
mirror.Interval = interval
970-
mirror.Repo = repo
971-
if err := repo_model.UpdateMirror(mirror); err != nil {
972-
log.Error("Failed to Set Mirror Interval: %s", err)
973-
ctx.Error(http.StatusUnprocessableEntity, "MirrorInterval", err)
974-
return err
975-
}
976-
log.Trace("Repository %s/%s Mirror Interval was Updated to %s", ctx.Repo.Owner.Name, repo.Name, interval)
977-
} else {
978-
log.Error("Wrong format for MirrorInternal Sent: %s", err)
986+
987+
// Ensure the provided duration is not too short
988+
if interval != 0 && interval < setting.Mirror.MinInterval {
989+
err := fmt.Errorf("invalid mirror interval: %s is below minimum interval: %s", interval, setting.Mirror.MinInterval)
979990
ctx.Error(http.StatusUnprocessableEntity, "MirrorInterval", err)
980991
return err
981992
}
993+
994+
mirror.Interval = interval
995+
mirror.Repo = repo
996+
mirror.ScheduleNextUpdate()
997+
log.Trace("Repository %s Mirror[%d] Set Interval: %s NextUpdateUnix: %s", repo.FullName(), mirror.ID, interval, mirror.NextUpdateUnix)
982998
}
999+
1000+
// update EnablePrune
1001+
if opts.EnablePrune != nil {
1002+
mirror.EnablePrune = *opts.EnablePrune
1003+
log.Trace("Repository %s Mirror[%d] Set EnablePrune: %t", repo.FullName(), mirror.ID, mirror.EnablePrune)
1004+
}
1005+
1006+
// finally update the mirror in the DB
1007+
if err := repo_model.UpdateMirror(mirror); err != nil {
1008+
log.Error("Failed to Set Mirror Interval: %s", err)
1009+
ctx.Error(http.StatusUnprocessableEntity, "MirrorInterval", err)
1010+
return err
1011+
}
1012+
9831013
return nil
9841014
}
9851015

routers/api/v1/user/email.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ func AddEmail(ctx *context.APIContext) {
8080
if err := user_model.AddEmailAddresses(emails); err != nil {
8181
if user_model.IsErrEmailAlreadyUsed(err) {
8282
ctx.Error(http.StatusUnprocessableEntity, "", "Email address has been used: "+err.(user_model.ErrEmailAlreadyUsed).Email)
83-
} else if user_model.IsErrEmailCharIsNotSupported(err) ||
84-
user_model.IsErrEmailInvalid(err) {
85-
errMsg := fmt.Sprintf("Email address %s invalid", err.(user_model.ErrEmailInvalid).Email)
83+
} else if user_model.IsErrEmailCharIsNotSupported(err) || user_model.IsErrEmailInvalid(err) {
84+
email := ""
85+
if typedError, ok := err.(user_model.ErrEmailInvalid); ok {
86+
email = typedError.Email
87+
}
88+
if typedError, ok := err.(user_model.ErrEmailCharIsNotSupported); ok {
89+
email = typedError.Email
90+
}
91+
92+
errMsg := fmt.Sprintf("Email address %q invalid", email)
8693
ctx.Error(http.StatusUnprocessableEntity, "", errMsg)
8794
} else {
8895
ctx.Error(http.StatusInternalServerError, "AddEmailAddresses", err)

routers/api/v1/user/key.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,21 @@ func DeletePublicKey(ctx *context.APIContext) {
266266
id := ctx.ParamsInt64(":id")
267267
externallyManaged, err := asymkey_model.PublicKeyIsExternallyManaged(id)
268268
if err != nil {
269-
ctx.Error(http.StatusInternalServerError, "PublicKeyIsExternallyManaged", err)
269+
if asymkey_model.IsErrKeyNotExist(err) {
270+
ctx.NotFound()
271+
} else {
272+
ctx.Error(http.StatusInternalServerError, "PublicKeyIsExternallyManaged", err)
273+
}
274+
return
270275
}
276+
271277
if externallyManaged {
272278
ctx.Error(http.StatusForbidden, "", "SSH Key is externally managed for this user")
279+
return
273280
}
274281

275282
if err := asymkey_service.DeletePublicKey(ctx.User, id); err != nil {
276-
if asymkey_model.IsErrKeyNotExist(err) {
277-
ctx.NotFound()
278-
} else if asymkey_model.IsErrKeyAccessDenied(err) {
283+
if asymkey_model.IsErrKeyAccessDenied(err) {
279284
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
280285
} else {
281286
ctx.Error(http.StatusInternalServerError, "DeletePublicKey", err)

routers/web/repo/setting.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"code.gitea.io/gitea/modules/repository"
3232
"code.gitea.io/gitea/modules/setting"
3333
"code.gitea.io/gitea/modules/structs"
34-
"code.gitea.io/gitea/modules/timeutil"
3534
"code.gitea.io/gitea/modules/typesniffer"
3635
"code.gitea.io/gitea/modules/util"
3736
"code.gitea.io/gitea/modules/validation"
@@ -194,11 +193,7 @@ func SettingsPost(ctx *context.Context) {
194193
} else {
195194
ctx.Repo.Mirror.EnablePrune = form.EnablePrune
196195
ctx.Repo.Mirror.Interval = interval
197-
if interval != 0 {
198-
ctx.Repo.Mirror.NextUpdateUnix = timeutil.TimeStampNow().AddDuration(interval)
199-
} else {
200-
ctx.Repo.Mirror.NextUpdateUnix = 0
201-
}
196+
ctx.Repo.Mirror.ScheduleNextUpdate()
202197
if err := repo_model.UpdateMirror(ctx.Repo.Mirror); err != nil {
203198
ctx.Data["Err_Interval"] = true
204199
ctx.RenderWithErr(ctx.Tr("repo.mirror_interval_invalid"), tplSettingsOptions, &form)

templates/base/footer_content.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<footer>
22
<div class="ui container">
33
<div class="ui left">
4-
{{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "powered_by" "Gitea"}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}: <strong>{{call .TmplLoadTimes}}</strong>{{end}}
4+
{{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "powered_by" "Gitea"}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if and .TmplLoadTimes ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}: <strong>{{call .TmplLoadTimes}}</strong>{{end}}
55
</div>
66
<div class="ui right links">
77
{{if .ShowFooterBranding}}

templates/swagger/v1_json.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14799,6 +14799,11 @@
1479914799
"type": "string",
1480014800
"x-go-name": "Description"
1480114801
},
14802+
"enable_prune": {
14803+
"description": "enable prune - remove obsolete remote-tracking references",
14804+
"type": "boolean",
14805+
"x-go-name": "EnablePrune"
14806+
},
1480214807
"external_tracker": {
1480314808
"$ref": "#/definitions/ExternalTracker"
1480414809
},

0 commit comments

Comments
 (0)