8000 temp · go-gitea/gitea@1c00cc3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c00cc3

Browse files
committed
temp
1 parent 7ee1d02 commit 1c00cc3

File tree

18 files changed

+111
-182
lines changed

18 files changed

+111
-182
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,10 +1156,9 @@ LEVEL = Info
11561156
;; Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo.
11571157
;RETARGET_CHILDREN_ON_MERGE = true
11581158
;;
1159-
;; Delay conflict checking until page view or API access, for pull requests that have not been updated in the specified number of days.
1160-
;; The default `-1` means never delay. With `1` day, pull requests under active development will be checked quickly without undue server
1161-
;; load for old pull requests.
1162-
;CHECK_ONLY_LAST_UPDATED_DAYS = -1
1159+
;; Delay mergeable check until page view or API access, for pull requests that have not been updated in the specified days when their base branches get updated.
1160+
;; Use "-1" to always check all pull requests (old behavior). Use "0" to always delay the checks.
1161+
;DELAY_CHECK_FOR_INACTIVE_DAYS = 7
11631162

11641163
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11651164
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

models/issues/pull.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"fmt"
1111
"io"
1212
"regexp"
13-
"strconv"
1413
"strings"
1514

1615
"code.gitea.io/gitea/models/db"
@@ -104,27 +103,6 @@ const (
104103
PullRequestStatusAncestor
105104
)
106105

107-
func (status PullRequestStatus) String() string {
108-
switch status {
109-
case PullRequestStatusConflict:
110-
return "CONFLICT"
111-
case PullRequestStatusChecking:
112-
return "CHECKING"
113-
case PullRequestStatusMergeable:
114-
return "MERGEABLE"
115-
case PullRequestStatusManuallyMerged:
116-
return "MANUALLY_MERGED"
117-
case PullRequestStatusError:
118-
return "ERROR"
119-
case PullRequestStatusEmpty:
120-
return "EMPTY"
121-
case PullRequestStatusAncestor:
122-
return "ANCESTOR"
123-
default:
124-
return strconv.Itoa(int(status))
125-
}
126-
}
127-
128106
// PullRequestFlow the flow of pull request
129107
type PullRequestFlow int
130108

modules/setting/repository.go

Lines changed: 3 additions & 3 deletions
201
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var (
8282
AddCoCommitterTrailers bool
8383
TestConflictingPatchesWithGitApply bool
8484
RetargetChildrenOnMerge bool
85-
CheckOnlyLastUpdatedDays int
85+
DelayCheckForInactiveDays int
8686
} `ini:"repository.pull-request"`
8787

8888
// Issue Setting
@@ -201,7 +201,7 @@ var (
201
AddCoCommitterTrailers bool
202202
TestConflictingPatchesWithGitApply bool
203203
RetargetChildrenOnMerge bool
204-
CheckOnlyLastUpdatedDays int
204+
DelayCheckForInactiveDays int
205205
}{
206206
WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
207207
// Same as GitHub. See
@@ -217,7 +217,7 @@ var (
217217
PopulateSquashCommentWithCommitMessages: false,
218218
AddCoCommitterTrailers: true,
219219
RetargetChildrenOnMerge: true,
220-
CheckOnlyLastUpdatedDays: -1,
220+
DelayCheckForInactiveDays: 7,
221221
},
222222

223223
// Issue settings

routers/api/v1/repo/pull.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func GetPullRequest(ctx *context.APIContext) {
204204
}
205205

206206
// Consider API access a view for delayed checking.
207-
pull_service.AddToTaskQueueOnView(ctx, pr)
207+
pull_service.StartPullRequestCheckOnView(ctx, pr)
208208

209209
ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(ctx, pr, ctx.Doer))
210210
}
@@ -293,7 +293,7 @@ func GetPullRequestByBaseHead(ctx *context.APIContext) {
293293
}
294294

295295
// Consider API access a view for delayed checking.
296-
pull_service.AddToTaskQueueOnView(ctx, pr)
296+
pull_service.StartPullRequestCheckOnView(ctx, pr)
297297

298298
ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(ctx, pr, ctx.Doer))
299299
}
@@ -929,15 +929,15 @@ func MergePullRequest(ctx *context.APIContext) {
929929
if err := pull_service.CheckPullMergeable(ctx, ctx.Doer, &ctx.Repo.Permission, pr, mergeCheckType, form.ForceMerge); err != nil {
930930
if errors.Is(err, pull_service.ErrIsClosed) {
931931
ctx.APIErrorNotFound()
932-
} else if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) {
932+
} else if errors.Is(err, pull_service.ErrNoPermissionToMerge) {
933933
ctx.APIError(http.StatusMethodNotAllowed, "User not allowed to merge PR")
934934
} else if errors.Is(err, pull_service.ErrHasMerged) {
935935
ctx.APIError(http.StatusMethodNotAllowed, "")
936936
} else if errors.Is(err, pull_service.ErrIsWorkInProgress) {
937937
ctx.APIError(http.StatusMethodNotAllowed, "Work in progress PRs cannot be merged")
938938
} else if errors.Is(err, pull_service.ErrNotMergeableState) {
939939
ctx.APIError(http.StatusMethodNotAllowed, "Please try again later")
940-
} else if pull_service.IsErrDisallowedToMerge(err) {
940+
} else if errors.Is(err, pull_service.ErrNotReadyToMerge) {
941941
ctx.APIError(http.StatusMethodNotAllowed, err)
942942
} else if asymkey_service.IsErrWontSign(err) {
943943
ctx.APIError(http.StatusMethodNotAllowed, err)

routers/private/hook_pre_receive.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package private
55

66
import (
7+
"errors"
78
"fmt"
89
"net/http"
910
"os"
@@ -374,7 +375,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r
374375

375376
// Check all status checks and reviews are ok
376377
if err := pull_service.CheckPullBranchProtections(ctx, pr, true); err != nil {
377-
if pull_service.IsErrDisallowedToMerge(err) {
378+
if errors.Is(err, pull_service.ErrNotReadyToMerge) {
378379
log.Warn("Forbidden: User %d is not allowed push to protected branch %s in %-v and pr #%d is not ready to be merged: %s", ctx.opts.UserID, branchName, repo, pr.Index, err.Error())
379380
ctx.JSON(http.StatusForbidden, private.Response{
380381
UserMsg: fmt.Sprintf("Not allowed to push to protected branch %s and pr #%d is not ready to be merged: %s", branchName, ctx.opts.PullRequestID, err.Error()),

routers/web/repo/issue_comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func NewComment(ctx *context.Context) {
9696
// Regenerate patch and test conflict.
9797
if pr == nil {
9898
issue.PullRequest.HeadCommitID = ""
99-
pull_service.AddToTaskQueue(ctx, issue.PullRequest)
99+
pull_service.StartPullRequestCheckImmediately(ctx, issue.PullRequest)
100100
}
101101

102102
// check whether the ref of PR <refs/pulls/pr_index/head> in base repo is consistent with the head commit of head branch in the head repo

routers/web/repo/issue_view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ func preparePullViewReviewAndMerge(ctx *context.Context, issue *issues_model.Iss
792792
allowMerge := false
793793
canWriteToHeadRepo := false
794794

795-
pull_service.AddToTaskQueueOnView(ctx, pull)
795+
pull_service.StartPullRequestCheckOnView(ctx, pull)
796796

797797
if ctx.IsSigned {
798798
if err := pull.LoadHeadRepo(ctx); err != nil {

routers/web/repo/pull.go

Lines changed: 2 additions & 2 de 10000 letions
Original file line numberDiff line numberDiff line change
@@ -1052,15 +1052,15 @@ func MergePullRequest(ctx *context.Context) {
10521052
} else {
10531053
ctx.JSONError(ctx.Tr("repo.issues.closed_title"))
10541054
}
1055-
case errors.Is(err, pull_service.ErrUserNotAllowedToMerge):
1055+
case errors.Is(err, pull_service.ErrNoPermissionToMerge):
10561056
ctx.JSONError(ctx.Tr("repo.pulls.update_not_allowed"))
10571057
case errors.Is(err, pull_service.ErrHasMerged):
10581058
ctx.JSONError(ctx.Tr("repo.pulls.has_merged"))
10591059
case errors.Is(err, pull_service.ErrIsWorkInProgress):
10601060
ctx.JSONError(ctx.Tr("repo.pulls.no_merge_wip"))
10611061
case errors.Is(err, pull_service.ErrNotMergeableState):
10621062
ctx.JSONError(ctx.Tr("repo.pulls.no_merge_not_ready"))
1063-
case pull_service.IsErrDisallowedToMerge(err):
1063+
case errors.Is(err, pull_service.ErrNotReadyToMerge):
10641064
ctx.JSONError(ctx.Tr("repo.pulls.no_merge_not_ready"))
10651065
case asymkey_service.IsErrWontSign(err):
10661066
ctx.JSONError(err.Error()) // has no translation ...

services/agit/agit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
204204
return nil, fmt.Errorf("failed to update pull ref. Error: %w", err)
205205
}
206206

207-
pull_service.AddToTaskQueue(ctx, pr)
207+
pull_service.StartPullRequestCheckImmediately(ctx, pr)
208208
err = pr.LoadIssue(ctx)
209209
if err != nil {
210210
return nil, fmt.Errorf("failed to load pull issue. Error: %w", err)

services/automerge/automerge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func handlePullRequestAutoMerge(pullID int64, sha string) {
289289
}
290290

291291
if err := pull_service.CheckPullMergeable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil {
292-
if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) {
292+
if errors.Is(err, pull_service.ErrNotReadyToMerge) {
293293
log.Info("%-v was scheduled to automerge by an unauthorized user", pr)
294294
return
295295
}

0 commit comments

Comments
 (0)
0