Skip to content

Commit 0202a36

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (21 commits) Update minimum password length requirements (go-gitea#25946) cynkra is covered via oc links now (go-gitea#26641) update config docs url (go-gitea#26640) devpod use go1.21 (go-gitea#26637) Use correct minio error (go-gitea#26634) Remove avatarHTML from template helpers (go-gitea#26598) Add optimistic lock to ActionRun table (go-gitea#26563) Improve the branch selector tab UI (go-gitea#26631) Improve translation of milestone filters (go-gitea#26569) Add `branch_filter` to hooks API endpoints (go-gitea#26599) Replace box-shadow for `floating` dropdown as well (go-gitea#26581) Add link to job details and tooltip to commit status in repo list in dashboard (go-gitea#26326) Ignore the trailing slashes when comparing oauth2 redirect_uri (go-gitea#26597) Update tool dependencies (go-gitea#26607) bump go to 1.21 (go-gitea#26608) Update 1.20.3 changelog (go-gitea#26609) Fix NPM packages name validation (go-gitea#26595) Use "input" event instead of "keyup" event for migration form (go-gitea#26602) Do not use deprecated log config options by default (go-gitea#26592) fix reopen logic for agit flow pull request (go-gitea#26399) ...
2 parents 1f3ed03 + b3f7137 commit 0202a36

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

+511
-357
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Gitea DevContainer",
3-
"image": "mcr.microsoft.com/devcontainers/go:1.20-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.21-bullseye",
44
"features": {
55
// installs nodejs into container
66
"ghcr.io/devcontainers/features/node:1": {

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ jobs:
7171
7272
swagger:
7373
- "templates/swagger/v1_json.tmpl"
74+
- "Makefile"

CHANGELOG.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ 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.com).
66

7-
## [1.20.3](https://github.com/go-gitea/gitea/releases/tag/v1.20.3) - 2023-08-07
7+
## [1.20.3](https://github.com/go-gitea/gitea/releases/tag/v1.20.3) - 2023-08-20
88

99
* BREAKING
1010
* Fix the wrong derive path (#26271) (#26318)
1111
* SECURITY
1212
* Fix API leaking Usermail if not logged in (#25097) (#26350)
13+
* FEATURES
14+
* Add ThreadID parameter for Telegram webhooks (#25996) (#26480)
1315
* ENHANCEMENTS
16+
* Add minimum polyfill to support "relative-time-element" in PaleMoon (#26575) (#26578)
17+
* Fix dark theme highlight for "NameNamespace" (#26519) (#26527)
18+
* Detect ogg mime-type as audio or video (#26494) (#26505)
19+
* Use `object-fit: contain` for oauth2 custom icons (#26493) (#26498)
20+
* Move dropzone progress bar to bottom to show filename when uploading (#26492) (#26497)
21+
* Remove last newline from config file (#26468) (#26471)
22+
* Minio: add missing region on client initialization (#26412) (#26438)
23+
* Add pull request review request webhook event (#26401) (#26407)
24+
* Fix text truncate (#26354) (#26384)
25+
* Fix incorrect color of selected assignees when create issue (#26324) (#26372)
1426
* Display human-readable text instead of cryptic filemodes (#26352) (#26358)
1527
* Hide `last indexed SHA` when a repo could not be indexed yet (#26340) (#26345)
1628
* Fix the topic validation rule and suport dots (#26286) (#26303)
@@ -19,6 +31,23 @@ been added to each release, please refer to the [blog](https://blog.gitea.com).
1931
* Fix commit compare style (#26209) (#26226)
2032
* Warn instead of reporting an error when a webhook cannot be found (#26039) (#26211)
2133
* BUGFIXES
34+
* Use "input" event instead of "keyup" event for migration form (#26602) (#26605)
35+
* Do not use deprecated log config options by default (#26592) (#26600)
36+
* Fix "issueReposQueryPattern does not match query" (#26556) (#26564)
37+
* Sync repo's IsEmpty status correctly (#26517) (#26560)
38+
* Fix project filter bugs (#26490) (#26558)
39+
* Use `hidden` over `clip` for text truncation (#26520) (#26522)
40+
* Set "type=button" for editor's toolbar buttons (#26510) (#26518)
41+
* Fix NuGet search endpoints (#25613) (#26499)
42+
* Fix storage path logic especially for relative paths (#26441) (#26481)
43+
* Close stdout correctly for "git blame" (#26470) (#26473)
44+
* Check first if minio bucket exists before trying to create it (#26420) (#26465)
45+
* Avoiding accessing undefined tributeValues #26461 (#26462)
46+
* Call git.InitSimple for runRepoSyncReleases (#26396) (#26450)
47+
* Add transaction when creating pull request created dirty data (#26259) (#26437)
48+
* Fix wrong middleware sequence (#26428) (#26436)
49+
* Fix admin queue page title and fix CI failures (#26409) (#26421)
50+
* Introduce ctx.PathParamRaw to avoid incorrect unescaping (#26392) (#26405)
2251
* Bypass MariaDB performance bug of the "IN" sub-query, fix incorrect IssueIndex (#26279) (#26368)
2352
* Fix incorrect CLI exit code and duplicate error message (#26346) (#26347)
2453
* Prevent newline errors with Debian packages (#26332) (#26342)
@@ -31,6 +60,8 @@ been added to each release, please refer to the [blog](https://blog.gitea.com).
3160
* Fix attachment clipboard copy on insecure origin (#26224) (#26231)
3261
* Fix access check for org-level project (#26182) (#26223)
3362
* MISC
63+
* Improve profile readme rendering (#25988) (#26453)
64+
* [docs] Add missing backtick in quickstart.zh-cn.md (#26349) (#26357)
3465
* Upgrade x/net to 0.13.0 (#26301)
3566

3667
## [1.20.2](https://github.com/go-gitea/gitea/releases/tag/v1.20.2) - 2023-07-29

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM docker.io/library/golang:1.20-alpine3.18 AS build-env
2+
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

Dockerfile.rootless

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM docker.io/library/golang:1.20-alpine3.18 AS build-env
2+
FROM docker.io/library/golang:1.21-alpine3.18 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ SHASUM ?= shasum -a 256
2323
HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes)
2424
COMMA := ,
2525

26-
XGO_VERSION := go-1.20.x
26+
XGO_VERSION := go-1.21.x
2727

2828
AIR_PACKAGE ?= github.com/cosmtrek/[email protected]
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.53.3
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/[email protected]
37-
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/[email protected].0
37+
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/[email protected].1
3838
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/[email protected]
3939

4040
DOCKER_IMAGE ?= gitea/gitea

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ Translations are done through Crowdin. If you want to translate to a new languag
110110

111111
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 to fill it as questions pop up.
112112

113-
https://docs.gitea.io/en-us/contributing/translation-guidelines/
113+
https://docs.gitea.com/contributing/localization
114114

115115
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
116116

117117
## Further information
118118

119-
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).
119+
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.com/).
120120
If you have questions that are not covered by the documentation, you can get in contact with us on our [Discord server](https://discord.gg/Gitea) or create a post in the [discourse forum](https://discourse.gitea.io/).
121121

122122
We maintain a list of Gitea-related projects at [gitea/awesome-gitea](https://gitea.com/gitea/awesome-gitea).
@@ -151,7 +151,6 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
151151
<a href="https://opencollective.com/gitea/sponsor/7/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/7/avatar.svg"></a>
152152
<a href="https://opencollective.com/gitea/sponsor/8/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/8/avatar.svg"></a>
153153
<a href="https://opencollective.com/gitea/sponsor/9/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/9/avatar.svg"></a>
154-
<a href="https://cynkra.com/" target="_blank"><img src="https://images.opencollective.com/cynkra/logo/square/64/192.png"></a>
155154

156155
## FAQ
157156

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
;; Do not copy the whole file as-is, as it contains some invalid sections for illustrative purposes.
55
;; If you don't know what a setting is you should not set it.
66
;;
7-
;; see https://docs.gitea.io/en-us/config-cheat-sheet/ for additional documentation.
7+
;; see https://docs.gitea.com/administration/config-cheat-sheet for additional documentation.
88

99

1010
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -454,7 +454,7 @@ INTERNAL_TOKEN=
454454
;REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128
455455
;;
456456
;; The minimum password length for new Users
457-
;MIN_PASSWORD_LENGTH = 6
457+
;MIN_PASSWORD_LENGTH = 8
458458
;;
459459
;; Set to true to allow users to import local server paths
460460
;IMPORT_LOCAL_PATHS = false

docker/root/etc/templates/app.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ PATH = /data/gitea/attachments
4646
[log]
4747
MODE = console
4848
LEVEL = info
49-
ROUTER = console
5049
ROOT_PATH = /data/gitea/log
5150

5251
[security]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ And the following unique queues:
559559
- `scrypt`: `scrypt$65536$16$2$50`
560560
- Adjusting the algorithm parameters using this functionality is done at your own risk.
561561
- `CSRF_COOKIE_HTTP_ONLY`: **true**: Set false to allow JavaScript to read CSRF cookie.
562-
- `MIN_PASSWORD_LENGTH`: **6**: Minimum password length for new users.
562+
- `MIN_PASSWORD_LENGTH`: **8**: Minimum password length for new users.
563563
- `PASSWORD_COMPLEXITY`: **off**: Comma separated list of character classes required to pass minimum complexity. If left empty or no valid values are specified, checking is disabled (off):
564564
- lower - use one or more lower latin characters
565565
- upper - use one or more upper latin characters

models/actions/run.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type ActionRun struct {
4343
EventPayload string `xorm:"LONGTEXT"`
4444
TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow
4545
Status Status `xorm:"index"`
46+
Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
4647
Started timeutil.TimeStamp
4748
Stopped timeutil.TimeStamp
4849
Created timeutil.TimeStamp `xorm:"created"`
@@ -332,12 +333,22 @@ func GetRunByIndex(ctx context.Context, repoID, index int64) (*ActionRun, error)
332333
return run, nil
333334
}
334335

336+
// UpdateRun updates a run.
337+
// It requires the inputted run has Version set.
338+
// It will return error if the version is not matched (it means the run has been changed after loaded).
335339
func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
336340
sess := db.GetEngine(ctx).ID(run.ID)
337341
if len(cols) > 0 {
338342
sess.Cols(cols...)
339343
}
340-
_, err := sess.Update(run)
344+
affected, err := sess.Update(run)
345+
if err != nil {
346+
return err
347+
}
348+
if affected == 0 {
349+
return fmt.Errorf("run has changed")
350+
// It's impossible that the run is not found, since Gitea never deletes runs.
351+
}
341352

342353
if run.Status != 0 || util.SliceContains(cols, "status") {
343354
if run.RepoID == 0 {
@@ -358,7 +369,7 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
358369
}
359370
}
360371

361-
return err
372+
return nil
362373
}
363374

364375
type ActionRunIndex db.ResourceIndex

models/actions/run_job.go

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,41 @@ func UpdateRunJob(ctx context.Context, job *ActionRunJob, cond builder.Cond, col
114114
if affected != 0 && util.SliceContains(cols, "status") && job.Status.IsWaiting() {
115115
// if the status of job changes to waiting again, increase tasks version.
116116
if err := IncreaseTaskVersion(ctx, job.OwnerID, job.RepoID); err != nil {
117-
return affected, err
117+
return 0, err
118118
}
119119
}
120120

121121
if job.RunID == 0 {
122122
var err error
123123
if job, err = GetRunJobByID(ctx, job.ID); err != nil {
124-
return affected, err
124+
return 0, err
125125
}
126126
}
127127

128-
jobs, err := GetRunJobsByRunID(ctx, job.RunID)
129-
if err != nil {
130-
return affected, err
128+
{
129+
// Other goroutines may aggregate the status of the run and update it too.
130+
// So we need load the run and its jobs before updating the run.
131+
run, err := GetRunByID(ctx, job.RunID)
132+
if err != nil {
133+
return 0, err
134+
}
135+
jobs, err := GetRunJobsByRunID(ctx, job.RunID)
136+
if err != nil {
137+
return 0, err
138+
}
139+
run.Status = aggregateJobStatus(jobs)
140+
if run.Started.IsZero() && run.Status.IsRunning() {
141+
run.Started = timeutil.TimeStampNow()
142+
}
143+
if run.Stopped.IsZero() && run.Status.IsDone() {
144+
run.Stopped = timeutil.TimeStampNow()
145+
}
146+
if err := UpdateRun(ctx, run, "status", "started", "stopped"); err != nil {
147+
return 0, fmt.Errorf("update run %d: %w", run.ID, err)
148+
}
131149
}
132150

133-
runStatus := aggregateJobStatus(jobs)
134-
135-
run := &ActionRun{
136-
ID: job.RunID,
137-
Status: runStatus,
138-
}
139-
if runStatus.IsDone() {
140-
run.Stopped = timeutil.TimeStampNow()
141-
}
142-
return affected, UpdateRun(ctx, run)
151+
return affected, nil
143152
}
144153

145154
func aggregateJobStatus(jobs []*ActionRunJob) Status {

models/actions/task.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,6 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
317317
return nil, false, nil
318318
}
319319

320-
if job.Run.Status.IsWaiting() {
321-
job.Run.Status = StatusRunning
322-
job.Run.Started = now
323-
if err := UpdateRun(ctx, job.Run, "status", "started"); err != nil {
324-
return nil, false, err
325-
}
326-
}
327-
328320
task.Job = job
329321

330322
if err := commiter.Commit(); err != nil {

models/auth/oauth2.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ func (app *OAuth2Application) TableName() string {
132132

133133
// ContainsRedirectURI checks if redirectURI is allowed for app
134134
func (app *OAuth2Application) ContainsRedirectURI(redirectURI string) bool {
135+
contains := func(s string) bool {
136+
s = strings.TrimSuffix(strings.ToLower(s), "/")
137+
for _, u := range app.RedirectURIs {
138+
if strings.TrimSuffix(strings.ToLower(u), "/") == s {
139+
return true
140+
}
141+
}
142+
return false
143+
}
135144
if !app.ConfidentialClient {
136145
uri, err := url.Parse(redirectURI)
137146
// ignore port for http loopback uris following https://datatracker.ietf.org/doc/html/rfc8252#section-7.3
@@ -140,13 +149,13 @@ func (app *OAuth2Application) ContainsRedirectURI(redirectURI string) bool {
140149
if ip != nil && ip.IsLoopback() {
141150
// strip port
142151
uri.Host = uri.Hostname()
143-
if util.SliceContainsString(app.RedirectURIs, uri.String(), true) {
152+
if contains(uri.String()) {
144153
return true
145154
}
146155
}
147156
}
148157
}
149-
return util.SliceContainsString(app.RedirectURIs, redirectURI, true)
158+
return contains(redirectURI)
150159
}
151160

152161
// Base32 characters, but lowercased.

models/auth/oauth2_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ func TestOAuth2Application_ContainsRedirectURI_WithPort(t *testing.T) {
6363
assert.False(t, app.ContainsRedirectURI(":"))
6464
}
6565

66+
func TestOAuth2Application_ContainsRedirect_Slash(t *testing.T) {
67+
app := &auth_model.OAuth2Application{RedirectURIs: []string{"http://127.0.0.1"}}
68+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1"))
69+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1/"))
70+
assert.False(t, app.ContainsRedirectURI("http://127.0.0.1/other"))
71+
72+
app = &auth_model.OAuth2Application{RedirectURIs: []string{"http://127.0.0.1/"}}
73+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1"))
74+
assert.True(t, app.ContainsRedirectURI("http://127.0.0.1/"))
75+
assert.False(t, app.ContainsRedirectURI("http://127.0.0.1/other"))
76+
}
77+
6678
func TestOAuth2Application_ValidateClientSecret(t *testing.T) {
6779
assert.NoError(t, unittest.PrepareTestDatabase())
6880
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})

models/git/commit_status.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"code.gitea.io/gitea/modules/setting"
2323
api "code.gitea.io/gitea/modules/structs"
2424
"code.gitea.io/gitea/modules/timeutil"
25+
"code.gitea.io/gitea/modules/translation"
2526

2627
"xorm.io/builder"
2728
"xorm.io/xorm"
@@ -191,6 +192,11 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {
191192
return status.Repo.APIURL() + "/statuses/" + url.PathEscape(status.SHA)
192193
}
193194

195+
// LocaleString returns the locale string name of the Status
196+
func (status *CommitStatus) LocaleString(lang translation.Locale) string {
197+
return lang.Tr("repo.commitstatus." + status.State.String())
198+
}
199+
194200
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
195201
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
196202
var lastStatus *CommitStatus

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ var migrations = []Migration{
524524
NewMigration("Fix PackageProperty typo", v1_21.FixPackagePropertyTypo),
525525
// v271 -> v272
526526
NewMigration("Allow archiving labels", v1_21.AddArchivedUnixColumInLabelTable),
527+
// v272 -> v273
528+
NewMigration("Add Version to ActionRun table", v1_21.AddVersionToActionRunTable),
527529
}
528530

529531
// GetCurrentDBVersion returns the current db version

models/migrations/v1_21/v272.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_21 //nolint
5+
import (
6+
"xorm.io/xorm"
7+
)
8+
9+
func AddVersionToActionRunTable(x *xorm.Engine) error {
10+
type ActionRun struct {
11+
Version int `xorm:"version default 0"`
12+
}
13+
return x.Sync(new(ActionRun))
14+
}

modules/packages/npm/creator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
ErrInvalidIntegrity = util.NewInvalidArgumentErrorf("failed to validate integrity")
3535
)
3636

37-
var nameMatch = regexp.MustCompile(`\A((@[^\s\/~'!\(\)\*]+?)[\/])?([^_.][^\s\/~'!\(\)\*]+)\z`)
37+
var nameMatch = regexp.MustCompile(`^(@[a-z0-9-][a-z0-9-._]*/)?[a-z0-9-][a-z0-9-._]*$`)
3838

3939
// Package represents a npm package
4040
type Package struct {

0 commit comments

Comments
 (0)