diff options
author | sillyguodong <33891828+sillyguodong@users.noreply.github.com> | 2023-05-08 14:39:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 14:39:32 +0800 |
commit | e962ade99cfd0471273f3dcf956c7cd222472758 (patch) | |
tree | bcaa2aeaf79ee6dc314a6903cac8b5395087c691 /services | |
parent | 80765aab8c71219ffd32689b3d15558157c25b85 (diff) | |
download | gitea-e962ade99cfd0471273f3dcf956c7cd222472758.tar.gz gitea-e962ade99cfd0471273f3dcf956c7cd222472758.zip |
Refresh the refernce of the closed PR when reopening (#24231)
Close #24213
Replace #23830
#### Cause
- Before, in order to making PR can get latest commit after reopening,
the `ref`(${REPO_PATH}/refs/pull/${PR_INDEX}/head) of evrey closed PR
will be updated when pushing commits to the `head branch` of the closed
PR.
#### Changes
- For closed PR , won't perform these behavior: insert`comment`, push
`notification` (UI and email), exectue
[pushToBaseRepo](https://github.com/go-gitea/gitea/blob/74225033413dc0f2b308bbe069f6d185b551e364/services/pull/pull.go#L409)
function and trigger `action` any more when pushing to the `head branch`
of the closed PR.
- Refresh the reference of the PR when reopening the closed PR (**even
if the head branch has been deleted before**). Make the reference of PR
consistent with the `head branch`.
Diffstat (limited to 'services')
-rw-r--r-- | services/pull/pull.go | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go index 55dfd3c180..8f2befa8ff 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -257,7 +257,8 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, // If you don't let it run all the way then you will lose data // TODO: graceful: AddTestPullRequestTask needs to become a queue! - prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch, true) + // GetUnmergedPullRequestsByHeadInfo() only return open and unmerged PR. + prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch) if err != nil { log.Error("Find pull requests [head_repo_id: %d, head_branch: %s]: %v", repoID, branch, err) return @@ -274,12 +275,9 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, continue } - // If the PR is closed, someone still push some commits to the PR, - // 1. We will insert comments of commits, but hidden until the PR is reopened. - // 2. We won't send any notification. AddToTaskQueue(pr) comment, err := CreatePushPullComment(ctx, doer, pr, oldCommitID, newCommitID) - if err == nil && comment != nil && !pr.Issue.IsClosed { + if err == nil && comment != nil { notification.NotifyPullRequestPushCommits(ctx, doer, pr, comment) } } @@ -294,10 +292,6 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string, } if err == nil { for _, pr := range prs { - if pr.Issue.IsClosed { - // The closed PR never trigger action or webhook - continue - } if newCommitID != "" && newCommitID != git.EmptySHA { changed, err := checkIfPRContentChanged(ctx, pr, oldCommitID, newCommitID) if err != nil { @@ -503,7 +497,7 @@ func (errs errlist) Error() string { // CloseBranchPulls close all the pull requests who's head branch is the branch func CloseBranchPulls(doer *user_model.User, repoID int64, branch string) error { - prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch, false) + prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repoID, branch) if err != nil { return err } @@ -539,7 +533,7 @@ func CloseRepoBranchesPulls(ctx context.Context, doer *user_model.User, repo *re var errs errlist for _, branch := range branches { - prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repo.ID, branch.Name, false) + prs, err := issues_model.GetUnmergedPullRequestsByHeadInfo(repo.ID, branch.Name) if err != nil { return err } |