Skip to content

Commit 849a130

Browse files
committed
Merge branch 'main' into test-must-change-password
2 parents 160ae72 + 4ae6b1a commit 849a130

File tree

87 files changed

+1028
-720
lines changed

Some content is hidden

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

87 files changed

+1028
-720
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-che
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected]
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
33-
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.4.1
33+
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.5.1
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
3636
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
@@ -397,11 +397,11 @@ lint-md: node_modules
397397

398398
.PHONY: lint-spell
399399
lint-spell:
400-
@go run $(MISSPELL_PACKAGE) -error $(SPELLCHECK_FILES)
400+
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -error $(SPELLCHECK_FILES)
401401

402402
.PHONY: lint-spell-fix
403403
lint-spell-fix:
404-
@go run $(MISSPELL_PACKAGE) -w $(SPELLCHECK_FILES)
404+
@go run $(MISSPELL_PACKAGE) -dict tools/misspellings.csv -w $(SPELLCHECK_FILES)
405405

406406
.PHONY: lint-go
407407
lint-go:
@@ -908,8 +908,9 @@ webpack: $(WEBPACK_DEST)
908908

909909
$(WEBPACK_DEST): $(WEBPACK_SOURCES) $(WEBPACK_CONFIGS) package-lock.json
910910
@$(MAKE) -s node-check node_modules
911-
rm -rf $(WEBPACK_DEST_ENTRIES)
912-
npx webpack
911+
@rm -rf $(WEBPACK_DEST_ENTRIES)
912+
@echo "Running webpack..."
913+
@BROWSERSLIST_IGNORE_OLD_DATA=true npx webpack
913914
@touch $(WEBPACK_DEST)
914915

915916
.PHONY: svg

custom/conf/app.example.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,8 @@ LEVEL = Info
15581558
;; email = use the username part of the email attribute
15591559
;; Note: `nickname`, `preferred_username` and `email` options will normalize input strings using the following criteria:
15601560
;; - diacritics are removed
1561-
;; - the characters in the set `['´\x60]` are removed
1562-
;; - the characters in the set `[\s~+]` are replaced with `-`
1561+
;; - the characters in the set ['´`] are removed
1562+
;; - the characters in the set [\s~+] are replaced with "-"
15631563
;USERNAME = nickname
15641564
;;
15651565
;; Update avatar if available from oauth2 provider.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ And the following unique queues:
612612
- `email` - use the username part of the email attribute
613613
- Note: `nickname`, `preferred_username` and `email` options will normalize input strings using the following criteria:
614614
- diacritics are removed
615-
- the characters in the set `['´\x60]` are removed
615+
- the characters in the set ```['´`]``` are removed
616616
- the characters in the set `[\s~+]` are replaced with `-`
617617
- `UPDATE_AVATAR`: **false**: Update avatar if available from oauth2 provider. Update will be performed on each login.
618618
- `ACCOUNT_LINKING`: **login**: How to handle if an account / email already exists:
@@ -1322,7 +1322,7 @@ Defaultly every storage has their default base path like below
13221322
| actions_log | actions_log/ |
13231323
| actions_artifacts | actions_artifacts/ |
13241324

1325-
And bucket, basepath or `SERVE_DIRECT` could be special or overrided, if you want to use a different you can:
1325+
And bucket, basepath or `SERVE_DIRECT` could be special or overridden, if you want to use a different you can:
13261326

13271327
```ini
13281328
[storage.actions_log]

models/actions/run.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ func (run *ActionRun) Link() string {
7474
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
7575
}
7676

77+
func (run *ActionRun) WorkflowLink() string {
78+
if run.Repo == nil {
79+
return ""
80+
}
81+
return fmt.Sprintf("%s/actions/?workflow=%s", run.Repo.Link(), run.WorkflowID)
82+
}
83+
7784
// RefLink return the url of run's ref
7885
func (run *ActionRun) RefLink() string {
7986
refName := git.RefName(run.Ref)
@@ -156,6 +163,10 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err
156163
return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
157164
}
158165

166+
func (run *ActionRun) IsSchedule() bool {
167+
return run.ScheduleID > 0
168+
}
169+
159170
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
160171
_, err := db.GetEngine(ctx).ID(repo.ID).
161172
SetExpr("num_action_runs",
@@ -251,11 +262,11 @@ func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID strin
251262

252263
// InsertRun inserts a run
253264
func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWorkflow) error {
254-
ctx, commiter, err := db.TxContext(ctx)
265+
ctx, committer, err := db.TxContext(ctx)
255266
if err != nil {
256267
return err
257268
}
258-
defer commiter.Close()
269+
defer committer.Close()
259270

260271
index, err := db.GetNextResourceIndex(ctx, "action_run_index", run.RepoID)
261272
if err != nil {
@@ -320,7 +331,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
320331
}
321332
}
322333

323-
return commiter.Commit()
334+
return committer.Commit()
324335
}
325336

326337
func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) {

models/actions/task.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ func GetRunningTaskByToken(ctx context.Context, token string) (*ActionTask, erro
216216
}
217217

218218
func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask, bool, error) {
219-
ctx, commiter, err := db.TxContext(ctx)
219+
ctx, committer, err := db.TxContext(ctx)
220220
if err != nil {
221221
return nil, false, err
222222
}
223-
defer commiter.Close()
223+
defer committer.Close()
224224

225225
e := db.GetEngine(ctx)
226226

@@ -322,7 +322,7 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
322322

323323
task.Job = job
324324

325-
if err := commiter.Commit(); err != nil {
325+
if err := committer.Commit(); err != nil {
326326
return nil, false, err
327327
}
328328

@@ -347,11 +347,11 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
347347
stepStates[v.Id] = v
348348
}
349349

350-
ctx, commiter, err := db.TxContext(ctx)
350+
ctx, committer, err := db.TxContext(ctx)
351351
if err != nil {
352352
return nil, err
353353
}
354-
defer commiter.Close()
354+
defer committer.Close()
355355

356356
e := db.GetEngine(ctx)
357357

@@ -412,7 +412,7 @@ func UpdateTaskByState(ctx context.Context, state *runnerv1.TaskState) (*ActionT
412412
}
413413
}
414414

415-
if err := commiter.Commit(); err != nil {
415+
if err := committer.Commit(); err != nil {
416416
return nil, err
417417
}
418418

models/actions/tasks_version.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
// ActionTasksVersion
1515
// If both ownerID and repoID is zero, its scope is global.
16-
// If ownerID is not zero and repoID is zero, its scope is org (there is no user-level runner currrently).
16+
// If ownerID is not zero and repoID is zero, its scope is org (there is no user-level runner currently).
1717
// If ownerID is zero and repoID is not zero, its scope is repo.
1818
type ActionTasksVersion struct {
1919
ID int64 `xorm:"pk autoincr"`
@@ -73,11 +73,11 @@ func increaseTasksVersionByScope(ctx context.Context, ownerID, repoID int64) err
7373
}
7474

7575
func IncreaseTaskVersion(ctx context.Context, ownerID, repoID int64) error {
76-
ctx, commiter, err := db.TxContext(ctx)
76+
ctx, committer, err := db.TxContext(ctx)
7777
if err != nil {
7878
return err
7979
}
80-
defer commiter.Close()
80+
defer committer.Close()
8181

8282
// 1. increase global
8383
if err := increaseTasksVersionByScope(ctx, 0, 0); err != nil {
@@ -101,5 +101,5 @@ func IncreaseTaskVersion(ctx context.Context, ownerID, repoID int64) error {
101101
}
102102
}
103103

104-
return commiter.Commit()
104+
return committer.Commit()
105105
}

models/fixtures/pull_request.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-
22
id: 1
33
type: 0 # gitea pull request
4-
status: 2 # mergable
4+
status: 2 # mergeable
55
issue_id: 2
66
index: 2
77
head_repo_id: 1
@@ -16,7 +16,7 @@
1616
-
1717
id: 2
1818
type: 0 # gitea pull request
19-
status: 2 # mergable
19+
status: 2 # mergeable
2020
issue_id: 3
2121
index: 3
2222
head_repo_id: 1
@@ -29,7 +29,7 @@
2929
-
3030
id: 3
3131
type: 0 # gitea pull request
32-
status: 2 # mergable
32+
status: 2 # mergeable
3333
issue_id: 8
3434
index: 1
3535
head_repo_id: 11
@@ -42,7 +42,7 @@
4242
-
4343
id: 4
4444
type: 0 # gitea pull request
45-
status: 2 # mergable
45+
status: 2 # mergeable
4646
issue_id: 9
4747
index: 1
4848
head_repo_id: 48
@@ -55,7 +55,7 @@
5555
-
5656
id: 5 # this PR is outdated (one commit behind branch1 )
5757
type: 0 # gitea pull request
58-
status: 2 # mergable
58+
status: 2 # mergeable
5959
issue_id: 11
6060
index: 5
6161
head_repo_id: 1
@@ -68,7 +68,7 @@
6868
-
6969
id: 6
7070
type: 0 # gitea pull request
71-
status: 2 # mergable
71+
status: 2 # mergeable
7272
issue_id: 12
7373
index: 2
7474
head_repo_id: 3
@@ -81,7 +81,7 @@
8181
-
8282
id: 7
8383
type: 0 # gitea pull request
84-
status: 2 # mergable
84+
status: 2 # mergeable
8585
issue_id: 19
8686
index: 1
8787
head_repo_id: 58
@@ -94,7 +94,7 @@
9494
-
9595
id: 8
9696
type: 0 # gitea pull request
97-
status: 2 # mergable
97+
status: 2 # mergeable
9898
issue_id: 20
9999
index: 1
100100
head_repo_id: 23
@@ -103,7 +103,7 @@
103103
-
104104
id: 9
105105
type: 0 # gitea pull request
106-
status: 2 # mergable
106+
status: 2 # mergeable
107107
issue_id: 21
108108
index: 1
109109
head_repo_id: 60
@@ -112,7 +112,7 @@
112112
-
113113
id: 10
114114
type: 0 # gitea pull request
115-
status: 2 # mergable
115+
status: 2 # mergeable
116116
issue_id: 22
117117
index: 1
118118
head_repo_id: 61

models/issues/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ func UpdateAllowEdits(ctx context.Context, pr *PullRequest) error {
807807

808808
// Mergeable returns if the pullrequest is mergeable.
809809
func (pr *PullRequest) Mergeable(ctx context.Context) bool {
810-
// If a pull request isn't mergable if it's:
810+
// If a pull request isn't mergeable if it's:
811811
// - Being conflict checked.
812812
// - Has a conflict.
813813
// - Received a error while being conflict checked.

models/issues/tracked_time.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ func AddTime(ctx context.Context, user *user_model.User, issue *Issue, amount in
187187
Issue: issue,
188188
Repo: issue.Repo,
189189
Doer: user,
190-
// Content before v1.21 did store the formated string instead of seconds,
191-
// so use "|" as delimeter to mark the new format
190+
// Content before v1.21 did store the formatted string instead of seconds,
191+
// so use "|" as delimiter to mark the new format
192192
Content: fmt.Sprintf("|%d", amount),
193193
Type: CommentTypeAddTimeManual,
194194
TimeID: t.ID,
@@ -267,8 +267,8 @@ func DeleteIssueUserTimes(ctx context.Context, issue *Issue, user *user_model.Us
267267
Issue: issue,
268268
Repo: issue.Repo,
269269
Doer: user,
270-
// Content before v1.21 did store the formated string instead of seconds,
271-
// so use "|" as delimeter to mark the new format
270+
// Content before v1.21 did store the formatted string instead of seconds,
271+
// so use "|" as delimiter to mark the new format
272272
Content: fmt.Sprintf("|%d", removedTime),
273273
Type: CommentTypeDeleteTimeManual,
274274
}); err != nil {
@@ -298,8 +298,8 @@ func DeleteTime(ctx context.Context, t *TrackedTime) error {
298298
Issue: t.Issue,
299299
Repo: t.Issue.Repo,
300300
Doer: t.User,
301-
// Content before v1.21 did store the formated string instead of seconds,
302-
// so use "|" as delimeter to mark the new format
301+
// Content before v1.21 did store the formatted string instead of seconds,
302+
// so use "|" as delimiter to mark the new format
303303
Content: fmt.Sprintf("|%d", t.Time),
304304
Type: CommentTypeDeleteTimeManual,
305305
}); err != nil {

models/migrations/v1_17/v216.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
package v1_17 //nolint
55

66
// This migration added non-ideal indices to the action table which on larger datasets slowed things down
7-
// it has been superceded by v218.go
7+
// it has been superseded by v218.go

models/unittest/testdb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"code.gitea.io/gitea/models/system"
1616
"code.gitea.io/gitea/modules/auth/password/hash"
1717
"code.gitea.io/gitea/modules/base"
18+
"code.gitea.io/gitea/modules/cache"
1819
"code.gitea.io/gitea/modules/git"
1920
"code.gitea.io/gitea/modules/log"
2021
"code.gitea.io/gitea/modules/setting"
@@ -114,6 +115,7 @@ func MainTest(m *testing.M, testOpts ...*TestOptions) {
114115
fatalTestError("Error creating test engine: %v\n", err)
115116
}
116117

118+
setting.IsInTesting = true
117119
setting.AppURL = "https://try.gitea.io/"
118120
setting.RunUser = "runuser"
119121
setting.SSH.User = "sshuser"
@@ -156,6 +158,9 @@ func MainTest(m *testing.M, testOpts ...*TestOptions) {
156158

157159
config.SetDynGetter(system.NewDatabaseDynKeyGetter())
158160

161+
if err = cache.Init(); err != nil {
162+
fatalTestError("cache.Init: %v\n", err)
163+
}
159164
if err = storage.Init(); err != nil {
160165
fatalTestError("storage.Init: %v\n", err)
161166
}

models/user/user.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,19 +501,19 @@ func GetUserSalt() (string, error) {
501501
// Note: The set of characters here can safely expand without a breaking change,
502502
// but characters removed from this set can cause user account linking to break
503503
var (
504-
customCharsReplacement = strings.NewReplacer("Æ", "AE")
505-
removeCharsRE = regexp.MustCompile(`['´\x60]`)
506-
removeDiacriticsTransform = transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
507-
replaceCharsHyphenRE = regexp.MustCompile(`[\s~+]`)
504+
customCharsReplacement = strings.NewReplacer("Æ", "AE")
505+
removeCharsRE = regexp.MustCompile("['`´]")
506+
transformDiacritics = transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
507+
replaceCharsHyphenRE = regexp.MustCompile(`[\s~+]`)
508508
)
509509

510-
// normalizeUserName returns a string with single-quotes and diacritics
511-
// removed, and any other non-supported username characters replaced with
512-
// a `-` character
510+
// NormalizeUserName only takes the name part if it is an email address, transforms it diacritics to ASCII characters.
511+
// It returns a string with the single-quotes removed, and any other non-supported username characters are replaced with a `-` character
513512
func NormalizeUserName(s string) (string, error) {
514-
strDiacriticsRemoved, n, err := transform.String(removeDiacriticsTransform, customCharsReplacement.Replace(s))
513+
s, _, _ = strings.Cut(s, "@")
514+
strDiacriticsRemoved, n, err := transform.String(transformDiacritics, customCharsReplacement.Replace(s))
515515
if err != nil {
516-
return "", fmt.Errorf("Failed to normalize character `%v` in provided username `%v`", s[n], s)
516+
return "", fmt.Errorf("failed to normalize the string of provided username %q at position %d", s, n)
517517
}
518518
return replaceCharsHyphenRE.ReplaceAllLiteralString(removeCharsRE.ReplaceAllLiteralString(strDiacriticsRemoved, ""), "-"), nil
519519
}

0 commit comments

Comments
 (0)