Skip to content

Commit a27850c

Browse files
committed
Merge remote-tracking branch 'giteaoffical/main'
* giteaoffical/main: Restore propagation of ErrDependenciesLeft (go-gitea#18325) Fix PR comments UI (go-gitea#18323) Make the height of the editor in Review Box smaller (4 lines as GitHub) (go-gitea#18319) Fix commit links on compare page (go-gitea#18310) Update JS dependencies, remove eslint-plugin-github (go-gitea#18317) Add MirrorUpdated field to Repository API type (go-gitea#18267) replace satori/go.uuid with gofrs/uuid (go-gitea#18311) Place inline diff comment dialogs in the 4th column. (go-gitea#18321) Use indirect comparison when showing pull requests (go-gitea#18313) Prevent ambiguous column error in organizations page (go-gitea#18314) Correctly upload LFS files (go-gitea#18316) [skip ci] Updated translations via Crowdin update description about vendoring in CONTRIBUTING.md (go-gitea#18280) Fix CheckRepoStats and reuse it during migration (go-gitea#18264) Minor tweak to tag list (go-gitea#18295)
2 parents 0fae813 + 4a20ead commit a27850c

Some content is hidden

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

41 files changed

+2064
-3170
lines changed

.eslintrc

+7-19
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]

CONTRIBUTING.md

+3-4
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

+6-5
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ checks: checks-frontend checks-backend
295295
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

go.mod

+8
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

+2-5
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

+13-24
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

+3-3
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

+1-1
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)