Skip to content

Commit b6f20b6

Browse files
authored
Merge branch 'main' into chroma-update
2 parents e62fc61 + 84f8ef3 commit b6f20b6

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

+2215
-3700
lines changed

.eslintrc

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ plugins:
1313
- eslint-plugin-import
1414
- eslint-plugin-vue
1515
- eslint-plugin-html
16-
- eslint-plugin-github
1716

1817
extends:
1918
- plugin:vue/recommended
@@ -96,23 +95,6 @@ rules:
9695
function-paren-newline: [0]
9796
generator-star-spacing: [0]
9897
getter-return: [2]
99-
github/array-foreach: [2]
100-
github/async-currenttarget: [2]
101-
github/async-preventdefault: [2]
102-
github/authenticity-token: [0]
103-
github/get-attribute: [2]
104-
github/js-class-name: [0]
105-
github/no-blur: [0]
106-
github/no-d-none: [0]
107-
github/no-dataset: [2]
108-
github/no-implicit-buggy-globals: [0]
109-
github/no-inner-html: [0]
110-
github/no-innerText: [2]
111-
github/no-then: [0]
112-
github/no-useless-passive: [2]
113-
github/prefer-observers: [0]
114-
github/require-passive-events: [2]
115-
github/unescaped-html-literal: [0]
11698
grouped-accessor-pairs: [2]
11799
guard-for-in: [0]
118100
id-blacklist: [0]
@@ -301,6 +283,7 @@ rules:
301283
no-unsafe-negation: [2]
302284
no-unused-expressions: [2]
303285
no-unused-labels: [2]
286+
no-unused-private-class-members: [2]
304287
no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, caughtErrorsIgnorePattern: ^_, ignoreRestSiblings: false}]
305288
no-use-before-define: [2, nofunc]
306289
no-useless-backreference: [0]
@@ -333,6 +316,7 @@ rules:
333316
prefer-exponentiation-operator: [2]
334317
prefer-named-capture-group: [0]
335318
prefer-numeric-literals: [2]
319+
prefer-object-has-own: [0]
336320
prefer-object-spread: [0]
337321
prefer-promise-reject-errors: [2, {allowEmptyReject: false}]
338322
prefer-regex-literals: [2]
@@ -379,7 +363,7 @@ rules:
379363
unicorn/import-style: [0]
380364
unicorn/new-for-builtins: [2]
381365
unicorn/no-abusive-eslint-disable: [0]
382-
unicorn/no-array-for-each: [0]
366+
unicorn/no-array-for-each: [2]
383367
unicorn/no-array-instanceof: [0]
384368
unicorn/no-array-method-this-argument: [2]
385369
unicorn/no-array-push-push: [2]
@@ -401,12 +385,14 @@ rules:
401385
unicorn/no-process-exit: [0]
402386
unicorn/no-reduce: [2]
403387
unicorn/no-static-only-class: [2]
388+
unicorn/no-thenable: [2]
404389
unicorn/no-this-assignment: [2]
405390
unicorn/no-unreadable-array-destructuring: [0]
406391
unicorn/no-unsafe-regex: [0]
407392
unicorn/no-unused-properties: [2]
408393
unicorn/no-useless-fallback-in-spread: [2]
409394
unicorn/no-useless-length-check: [2]
395+
unicorn/no-useless-promise-resolve-reject: [2]
410396
unicorn/no-useless-spread: [2]
411397
unicorn/no-useless-undefined: [0]
412398
unicorn/no-zero-fractions: [2]
@@ -426,6 +412,7 @@ rules:
426412
unicorn/prefer-event-key: [2]
427413
unicorn/prefer-export-from: [2]
428414
unicorn/prefer-includes: [2]
415+
unicorn/prefer-json-parse-buffer: [0]
429416
unicorn/prefer-math-trunc: [2]
430417
unicorn/prefer-modern-dom-apis: [0]
431418
unicorn/prefer-module: [2]
@@ -453,6 +440,7 @@ rules:
453440
unicorn/prefer-trim-start-end: [2]
454441
unicorn/prefer-type-error: [0]
455442
unicorn/prevent-abbreviations: [0]
443+
unicorn/relative-url-style: [2]
456444
unicorn/require-array-join-separator: [2]
457445
unicorn/require-number-to-fixed-digits-argument: [2]
458446
unicorn/require-post-message-target-origin: [0]

.ignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
/vendor
2-
/public/vendor/plugins
1+
*.min.css
2+
*.min.js
33
/modules/options/bindata.go
44
/modules/public/bindata.go
55
/modules/templates/bindata.go
6+
/public/vendor/plugins
7+
/vendor
8+
node_modules

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,12 @@ Here's how to run the test suite:
9191

9292
## Vendoring
9393

94-
We keep a cached copy of dependencies within the `vendor/` directory,
95-
managing updates via [Modules](https://golang.org/cmd/go/#hdr-Module_maintenance).
94+
We manage dependencies via [Go Modules](https://golang.org/cmd/go/#hdr-Module_maintenance), more details: [go mod](https://go.dev/ref/mod).
9695

97-
Pull requests should only include `vendor/` updates if they are part of
96+
Pull requests should only include `go.mod`, `go.sum` updates if they are part of
9897
the same change, be it a bugfix or a feature addition.
9998

100-
The `vendor/` update needs to be justified as part of the PR description,
99+
The `go.mod`, `go.sum` update needs to be justified as part of the PR description,
101100
and must be verified by the reviewers and/or merger to always reference
102101
an existing upstream commit.
103102

Makefile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ fmt-check:
292292
checks: checks-frontend checks-backend
293293

294294
.PHONY: checks-frontend
295-
checks-frontend: svg-check
295+
checks-frontend: lockfile-check svg-check
296296

297297
.PHONY: checks-backend
298-
checks-backend: swagger-check swagger-validate
298+
checks-backend: gomod-check swagger-check swagger-validate
299299

300300
.PHONY: lint
301301
lint: lint-frontend lint-backend
@@ -369,11 +369,12 @@ unit-test-coverage:
369369
vendor:
370370
$(GO) mod tidy && $(GO) mod vendor
371371

372-
.PHONY: test-vendor
373-
test-vendor: vendor
374-
@diff=$$(git diff vendor/); \
372+
.PHONY: gomod-check
373+
gomod-check:
374+
@$(GO) mod tidy
375+
@diff=$$(git diff go.sum); \
375376
if [ -n "$$diff" ]; then \
376-
echo "Please run 'make vendor' and commit the result:"; \
377+
echo "Please run '$(GO) mod tidy' and commit the result:"; \
377378
echo "$${diff}"; \
378379
exit 1; \
379380
fi
@@ -700,6 +701,17 @@ svg-check: svg
700701
exit 1; \
701702
fi
702703

704+
.PHONY: lockfile-check
705+
lockfile-check:
706+
npm install --package-lock-only
707+
@diff=$$(git diff package-lock.json); \
708+
if [ -n "$$diff" ]; then \
709+
echo "package-lock.json is inconsistent with package.json"; \
710+
echo "Please run 'npm install --package-lock-only' and commit the result:"; \
711+
echo "$${diff}"; \
712+
exit 1; \
713+
fi
714+
703715
.PHONY: update-translations
704716
update-translations:
705717
mkdir -p ./translations

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func fail(userMessage, logMessage string, args ...interface{}) error {
9292
if len(logMessage) > 0 {
9393
_ = private.SSHLog(ctx, true, fmt.Sprintf(logMessage+": ", args...))
9494
}
95-
return cli.NewExitError(fmt.Sprintf("Gitea: %s", userMessage), 1)
95+
return cli.NewExitError("", 1)
9696
}
9797

9898
func runServ(c *cli.Context) error {

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ This error indicates nginx is configured to restrict the file upload size.
128128

129129
In your nginx config file containing your Gitea proxy directive, find the `location { ... }` block for Gitea and add the line
130130
`client_max_body_size 16M;` to set this limit to 16 megabytes or any other number of choice.
131+
If you use Git LFS, this will also limit the size of the largest file you will be able to push.
131132

132133

133134
## Apache HTTPD

go.mod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,11 @@ replace github.com/markbates/goth v1.68.0 => github.com/zeripath/goth v1.68.1-0.
146146
replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142115-2c99e1ffdfa0
147147

148148
replace github.com/duo-labs/webauthn => github.com/authelia/webauthn v0.0.0-20211225121951-80d1f2a572e4
149+
150+
replace github.com/satori/go.uuid v1.2.0 => github.com/gofrs/uuid v4.2.0+incompatible
151+
152+
exclude github.com/gofrs/uuid v3.2.0+incompatible
153+
154+
exclude github.com/gofrs/uuid v4.0.0+incompatible
155+
156+
exclude github.com/goccy/go-json v0.4.11

go.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,10 @@ github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/V
489489
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
490490
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
491491
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
492-
github.com/goccy/go-json v0.4.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
493492
github.com/goccy/go-json v0.7.4 h1:B44qRUFwz/vxPKPISQ1KhvzRi9kZ28RAf6YtjriBZ5k=
494493
github.com/goccy/go-json v0.7.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
495-
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
496-
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
494+
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
495+
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
497496
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
498497
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
499498
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -1041,8 +1040,6 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
10411040
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10421041
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
10431042
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
1044-
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
1045-
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
10461043
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
10471044
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
10481045
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=

models/issue.go

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ func (issue *Issue) ReadBy(userID int64) error {
595595
return setIssueNotificationStatusReadIfUnread(db.GetEngine(db.DefaultContext), userID, issue.ID)
596596
}
597597

598-
func updateIssueCols(e db.Engine, issue *Issue, cols ...string) error {
599-
if _, err := e.ID(issue.ID).Cols(cols...).Update(issue); err != nil {
598+
func updateIssueCols(ctx context.Context, issue *Issue, cols ...string) error {
599+
if _, err := db.GetEngine(ctx).ID(issue.ID).Cols(cols...).Update(issue); err != nil {
600600
return err
601601
}
602602
return nil
@@ -646,7 +646,7 @@ func (issue *Issue) doChangeStatus(ctx context.Context, doer *user_model.User, i
646646
issue.ClosedUnix = 0
647647
}
648648

649-
if err := updateIssueCols(e, issue, "is_closed", "closed_unix"); err != nil {
649+
if err := updateIssueCols(ctx, issue, "is_closed", "closed_unix"); err != nil {
650650
return nil, err
651651
}
652652

@@ -662,12 +662,12 @@ func (issue *Issue) doChangeStatus(ctx context.Context, doer *user_model.User, i
662662

663663
// Update issue count of milestone
664664
if issue.MilestoneID > 0 {
665-
if err := updateMilestoneCounters(e, issue.MilestoneID); err != nil {
665+
if err := updateMilestoneCounters(ctx, issue.MilestoneID); err != nil {
666666
return nil, err
667667
}
668668
}
669669

670-
if err := issue.updateClosedNum(e); err != nil {
670+
if err := issue.updateClosedNum(ctx); err != nil {
671671
return nil, err
672672
}
673673

@@ -722,7 +722,7 @@ func (issue *Issue) ChangeTitle(doer *user_model.User, oldTitle string) (err err
722722
}
723723
defer committer.Close()
724724

725-
if err = updateIssueCols(db.GetEngine(ctx), issue, "name"); err != nil {
725+
if err = updateIssueCols(ctx, issue, "name"); err != nil {
726726
return fmt.Errorf("updateIssueCols: %v", err)
727727
}
728728

@@ -756,7 +756,7 @@ func (issue *Issue) ChangeRef(doer *user_model.User, oldRef string) (err error)
756756
}
757757
defer committer.Close()
758758

759-
if err = updateIssueCols(db.GetEngine(ctx), issue, "ref"); err != nil {
759+
if err = updateIssueCols(ctx, issue, "ref"); err != nil {
760760
return fmt.Errorf("updateIssueCols: %v", err)
761761
}
762762

@@ -847,7 +847,7 @@ func (issue *Issue) ChangeContent(doer *user_model.User, content string) (err er
847847

848848
issue.Content = content
849849

850-
if err = updateIssueCols(db.GetEngine(ctx), issue, "content"); err != nil {
850+
if err = updateIssueCols(ctx, issue, "content"); err != nil {
851851
return fmt.Errorf("UpdateIssueCols: %v", err)
852852
}
853853

@@ -956,7 +956,7 @@ func newIssue(ctx context.Context, doer *user_model.User, opts NewIssueOptions)
956956
}
957957

958958
if opts.Issue.MilestoneID > 0 {
959-
if err := updateMilestoneCounters(e, opts.Issue.MilestoneID); err != nil {
959+
if err := updateMilestoneCounters(ctx, opts.Issue.MilestoneID); err != nil {
960960
return err
961961
}
962962

@@ -1970,10 +1970,9 @@ func UpdateIssueDeadline(issue *Issue, deadlineUnix timeutil.TimeStamp, doer *us
19701970
return err
19711971
}
19721972
defer committer.Close()
1973-
sess := db.GetEngine(ctx)
19741973

19751974
// Update the deadline
1976-
if err = updateIssueCols(sess, &Issue{ID: issue.ID, DeadlineUnix: deadlineUnix}, "deadline_unix"); err != nil {
1975+
if err = updateIssueCols(ctx, &Issue{ID: issue.ID, DeadlineUnix: deadlineUnix}, "deadline_unix"); err != nil {
19771976
return err
19781977
}
19791978

@@ -2059,21 +2058,11 @@ func (issue *Issue) BlockingDependencies() ([]*DependencyInfo, error) {
20592058
return issue.getBlockingDependencies(db.GetEngine(db.DefaultContext))
20602059
}
20612060

2062-
func (issue *Issue) updateClosedNum(e db.Engine) (err error) {
2061+
func (issue *Issue) updateClosedNum(ctx context.Context) (err error) {
20632062
if issue.IsPull {
2064-
_, err = e.Exec("UPDATE `repository` SET num_closed_pulls=(SELECT count(*) FROM issue WHERE repo_id=? AND is_pull=? AND is_closed=?) WHERE id=?",
2065-
issue.RepoID,
2066-
true,
2067-
true,
2068-
issue.RepoID,
2069-
)
2063+
err = repoStatsCorrectNumClosed(ctx, issue.RepoID, true, "num_closed_pulls")
20702064
} else {
2071-
_, err = e.Exec("UPDATE `repository` SET num_closed_issues=(SELECT count(*) FROM issue WHERE repo_id=? AND is_pull=? AND is_closed=?) WHERE id=?",
2072-
issue.RepoID,
2073-
false,
2074-
true,
2075-
issue.RepoID,
2076-
)
2065+
err = repoStatsCorrectNumClosed(ctx, issue.RepoID, false, "num_closed_issues")
20772066
}
20782067
return
20792068
}

models/issue_comment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func (c *Comment) LoadPoster() error {
519519
return c.loadPoster(db.GetEngine(db.DefaultContext))
520520
}
521521

522-
// LoadAttachments loads attachments
522+
// LoadAttachments loads attachments (it never returns error, the error during `GetAttachmentsByCommentIDCtx` is ignored)
523523
func (c *Comment) LoadAttachments() error {
524524
if len(c.Attachments) > 0 {
525525
return nil
@@ -856,12 +856,12 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
856856
}
857857
}
858858
case CommentTypeReopen, CommentTypeClose:
859-
if err = opts.Issue.updateClosedNum(e); err != nil {
859+
if err = opts.Issue.updateClosedNum(ctx); err != nil {
860860
return err
861861
}
862862
}
863863
// update the issue's updated_unix column
864-
return updateIssueCols(e, opts.Issue, "updated_unix")
864+
return updateIssueCols(ctx, opts.Issue, "updated_unix")
865865
}
866866

867867
func createDeadlineComment(ctx context.Context, doer *user_model.User, issue *Issue, newDeadlineUnix timeutil.TimeStamp) (*Comment, error) {

models/issue_lock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
4646
}
4747
defer committer.Close()
4848

49-
if err := updateIssueCols(db.GetEngine(ctx), opts.Issue, "is_locked"); err != nil {
49+
if err := updateIssueCols(ctx, opts.Issue, "is_locked"); err != nil {
5050
return err
5151
}
5252

0 commit comments

Comments
 (0)