Skip to content

Commit 911c65a

Browse files
authored
Merge branch 'main' into lunny/fix_auth_bug
2 parents 0de0dc0 + 731d803 commit 911c65a

File tree

11 files changed

+51
-33
lines changed

11 files changed

+51
-33
lines changed

.github/workflows/cron-licenses.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
if: github.repository == 'go-gitea/gitea'
1212
steps:
1313
- uses: actions/checkout@v5
14-
- uses: actions/setup-go@v5
14+
- uses: actions/setup-go@v6
1515
with:
1616
go-version-file: go.mod
1717
check-latest: true

.github/workflows/pull-compliance.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v5
20-
- uses: actions/setup-go@v5
20+
- uses: actions/setup-go@v6
2121
with:
2222
go-version-file: go.mod
2323
check-latest: true
@@ -72,7 +72,7 @@ jobs:
7272
runs-on: ubuntu-latest
7373
steps:
7474
- uses: actions/checkout@v5
75-
- uses: actions/setup-go@v5
75+
- uses: actions/setup-go@v6
7676
with:
7777
go-version-file: go.mod
7878
check-latest: true
@@ -84,7 +84,7 @@ jobs:
8484
runs-on: ubuntu-latest
8585
steps:
8686
- uses: actions/checkout@v5
87-
- uses: actions/setup-go@v5
87+
- uses: actions/setup-go@v6
8888
with:
8989
go-version-file: go.mod
9090
check-latest: true
@@ -101,7 +101,7 @@ jobs:
101101
runs-on: ubuntu-latest
102102
steps:
103103
- uses: actions/checkout@v5
104-
- uses: actions/setup-go@v5
104+
- uses: actions/setup-go@v6
105105
with:
106106
go-version-file: go.mod
107107
check-latest: true
@@ -116,7 +116,7 @@ jobs:
116116
runs-on: ubuntu-latest
117117
steps:
118118
- uses: actions/checkout@v5
119-
- uses: actions/setup-go@v5
119+
- uses: actions/setup-go@v6
120120
with:
121121
go-version-file: go.mod
122122
check-latest: true
@@ -145,7 +145,7 @@ jobs:
145145
runs-on: ubuntu-latest
146146
steps:
147147
- uses: actions/checkout@v5
148-
- uses: actions/setup-go@v5
148+
- uses: actions/setup-go@v6
149149
with:
150150
go-version-file: go.mod
151151
check-latest: true
@@ -190,7 +190,7 @@ jobs:
190190
runs-on: ubuntu-latest
191191
steps:
192192
- uses: actions/checkout@v5
193-
- uses: actions/setup-go@v5
193+
- uses: actions/setup-go@v6
194194
with:
195195
go-version-file: go.mod
196196
check-latest: true

.github/workflows/pull-db-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- "9000:9000"
4040
steps:
4141
- uses: actions/checkout@v5
42-
- uses: actions/setup-go@v5
42+
- uses: actions/setup-go@v6
4343
with:
4444
go-version-file: go.mod
4545
check-latest: true
@@ -67,7 +67,7 @@ jobs:
6767
runs-on: ubuntu-latest
6868
steps:
6969
- uses: actions/checkout@v5
70-
- uses: actions/setup-go@v5
70+
- uses: actions/setup-go@v6
7171
with:
7272
go-version-file: go.mod
7373
check-latest: true
@@ -125,7 +125,7 @@ jobs:
125125
- 10000:10000
126126
steps:
127127
- uses: actions/checkout@v5
128-
- uses: actions/setup-go@v5
128+
- uses: actions/setup-go@v6
129129
with:
130130
go-version-file: go.mod
131131
check-latest: true
@@ -178,7 +178,7 @@ jobs:
178178
- "993:993"
179179
steps:
180180
- uses: actions/checkout@v5
181-
- uses: actions/setup-go@v5
181+
- uses: actions/setup-go@v6
182182
with:
183183
go-version-file: go.mod
184184
check-latest: true
@@ -218,7 +218,7 @@ jobs:
218218
- 10000:10000
219219
steps:
220220
- uses: actions/checkout@v5
221-
- uses: actions/setup-go@v5
221+
- uses: actions/setup-go@v6
222222
with:
223223
go-version-file: go.mod
224224
check-latest: true

.github/workflows/pull-e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v5
22-
- uses: actions/setup-go@v5
22+
- uses: actions/setup-go@v6
2323
with:
2424
go-version-file: go.mod
2525
check-latest: true

.github/workflows/release-nightly.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
1717
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
1818
- run: git fetch --unshallow --quiet --tags --force
19-
- uses: actions/setup-go@v5
19+
- uses: actions/setup-go@v6
2020
with:
2121
go-version-file: go.mod
2222
check-latest: true
@@ -65,7 +65,7 @@ jobs:
6565
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
6666
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
6767
- run: git fetch --unshallow --quiet --tags --force
68-
- uses: actions/setup-go@v5
68+
- uses: actions/setup-go@v6
6969
with:
7070
go-version-file: go.mod
7171
check-latest: true
@@ -107,7 +107,7 @@ jobs:
107107
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
108108
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
109109
- run: git fetch --unshallow --quiet --tags --force
110-
- uses: actions/setup-go@v5
110+
- uses: actions/setup-go@v6
111111
with:
112112
go-version-file: go.mod
113113
check-latest: true

.github/workflows/release-tag-rc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
1818
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
1919
- run: git fetch --unshallow --quiet --tags --force
20-
- uses: actions/setup-go@v5
20+
- uses: actions/setup-go@v6
2121
with:
2222
go-version-file: go.mod
2323
check-latest: true

.github/workflows/release-tag-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
# fetch all commits instead of only the last as some branches are long lived and could have many between versions
2222
# fetch all tags to ensure that "git describe" reports expected Gitea version, eg. v1.21.0-dev-1-g1234567
2323
- run: git fetch --unshallow --quiet --tags --force
24-
- uses: actions/setup-go@v5
24+
- uses: actions/setup-go@v6
2525
with:
2626
go-version-file: go.mod
2727
check-latest: true

services/issue/comments.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
user_model "code.gitea.io/gitea/models/user"
1616
"code.gitea.io/gitea/modules/gitrepo"
1717
"code.gitea.io/gitea/modules/json"
18+
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/timeutil"
1920
git_service "code.gitea.io/gitea/services/git"
2021
notify_service "code.gitea.io/gitea/services/notify"
@@ -151,15 +152,15 @@ func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_m
151152
}
152153

153154
// LoadCommentPushCommits Load push commits
154-
func LoadCommentPushCommits(ctx context.Context, c *issues_model.Comment) (err error) {
155+
func LoadCommentPushCommits(ctx context.Context, c *issues_model.Comment) error {
155156
if c.Content == "" || c.Commits != nil || c.Type != issues_model.CommentTypePullRequestPush {
156157
return nil
157158
}
158159

159160
var data issues_model.PushActionContent
160-
err = json.Unmarshal([]byte(c.Content), &data)
161-
if err != nil {
162-
return err
161+
if err := json.Unmarshal([]byte(c.Content), &data); err != nil {
162+
log.Debug("Unmarshal: %v", err) // no need to show 500 error to end user when the JSON is broken
163+
return nil
163164
}
164165

165166
c.IsForcePush = data.IsForcePush
@@ -168,9 +169,15 @@ func LoadCommentPushCommits(ctx context.Context, c *issues_model.Comment) (err e
168169
if len(data.CommitIDs) != 2 {
169170
return nil
170171
}
171-
c.OldCommit = data.CommitIDs[0]
172-
c.NewCommit = data.CommitIDs[1]
172+
c.OldCommit, c.NewCommit = data.CommitIDs[0], data.CommitIDs[1]
173173
} else {
174+
if err := c.LoadIssue(ctx); err != nil {
175+
return err
176+
}
177+
if err := c.Issue.LoadRepo(ctx); err != nil {
178+
return err
179+
}
180+
174181
gitRepo, closer, err := gitrepo.RepositoryFromContextOrOpen(ctx, c.Issue.Repo)
175182
if err != nil {
176183
return err
@@ -179,10 +186,11 @@ func LoadCommentPushCommits(ctx context.Context, c *issues_model.Comment) (err e
179186

180187
c.Commits, err = git_service.ConvertFromGitCommit(ctx, gitRepo.GetCommitsFromIDs(data.CommitIDs), c.Issue.Repo)
181188
if err != nil {
182-
return err
189+
log.Debug("ConvertFromGitCommit: %v", err) // no need to show 500 error to end user when the commit does not exist
190+
} else {
191+
c.CommitsNum = int64(len(c.Commits))
183192
}
184-
c.CommitsNum = int64(len(c.Commits))
185193
}
186194

187-
return err
195+
return nil
188196
}

services/pull/merge.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.U
248248
}
249249
defer releaser()
250250
defer func() {
251+
// This is a duplicated call to AddTestPullRequestTask (it will also be called by the post-receive hook, via a push queue).
252+
// This call will do some operations (push to base repo, sync commit divergence, add PR conflict check queue task, etc)
253+
// immediately instead of waiting for the "push queue"'s task. The code is from https://github.com/go-gitea/gitea/pull/7082.
254+
// But it's really questionable whether it's worth to do it ahead without waiting for the "push queue" task to run.
255+
// TODO: DUPLICATE-PR-TASK: maybe can try to remove this in 1.26 to see if there is any issue.
251256
go AddTestPullRequestTask(TestPullRequestOptions{
252257
RepoID: pr.BaseRepo.ID,
253258
Doer: doer,

services/pull/pull.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,8 @@ type TestPullRequestOptions struct {
374374
func AddTestPullRequestTask(opts TestPullRequestOptions) {
375375
log.Trace("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests", opts.RepoID, opts.Branch)
376376
graceful.GetManager().RunWithShutdownContext(func(ctx context.Context) {
377-
// There is no sensible way to shut this down ":-("
378-
// If you don't let it run all the way then you will lose data
379-
// TODO: graceful: AddTestPullRequestTask needs to become a queue!
380-
377+
// this function does a lot of operations to various models, if the process gets killed in the middle,
378+
// there is no way to recover at the moment. The best workaround is to let end user push again.
381379
repo, err := repo_model.GetRepositoryByID(ctx, opts.RepoID)
382380
if err != nil {
383381
log.Error("GetRepositoryByID: %v", err)
@@ -402,11 +400,15 @@ func AddTestPullRequestTask(opts TestPullRequestOptions) {
402400
continue
403401
}
404402

405-
StartPullRequestCheckImmediately(ctx, pr)
403+
// create push comment before check pull request status,
404+
// then when the status is mergeable, the comment is already in database, to make testing easy and stable
406405
comment, err := CreatePushPullComment(ctx, opts.Doer, pr, opts.OldCommitID, opts.NewCommitID, opts.IsForcePush)
407406
if err == nil && comment != nil {
408407
notify_service.PullRequestPushCommits(ctx, opts.Doer, pr, comment)
409408
}
409+
// The caller can be in a goroutine or a "push queue", "conflict check" can be time-consuming,
410+
// and the concurrency should be limited, so the conflict check will be done in another queue
411+
StartPullRequestCheckImmediately(ctx, pr)
410412
}
411413

412414
if opts.IsSync {

0 commit comments

Comments
 (0)