diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-25 10:48:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-25 10:48:22 +0800 |
commit | f2d12f7b034e32d0e7cc7b60e7ad015af122db3f (patch) | |
tree | 5009bac317f4dbed07c459aa5361583a4f3fc2b7 /modules | |
parent | ee26f042c421d90cbd3f852427de8b98f1cc71a7 (diff) | |
download | gitea-f2d12f7b034e32d0e7cc7b60e7ad015af122db3f.tar.gz gitea-f2d12f7b034e32d0e7cc7b60e7ad015af122db3f.zip |
Fix pull view when head repository or head branch missed and close related pull requests when delete head repository or head branch (#9927)
* fix pull view when head repository or head branch missed and close related pull requests when delete branch
* fix pull view broken when head repository deleted
* close pull requests when head repositories deleted
* Add tests for broken pull request head repository or branch
* fix typo
* ignore special error when close pull request
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/repofiles/update.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index 430a83093d..5188529d16 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -495,9 +495,18 @@ func PushUpdate(repo *models.Repository, branch string, opts PushUpdateOptions) return err } - log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name) + if !isDelRef { + if err = models.RemoveDeletedBranch(repo.ID, opts.Branch); err != nil { + log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, opts.Branch, err) + } + + log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name) - go pull_service.AddTestPullRequestTask(pusher, repo.ID, branch, true, opts.OldCommitID, opts.NewCommitID) + go pull_service.AddTestPullRequestTask(pusher, repo.ID, branch, true, opts.OldCommitID, opts.NewCommitID) + // close all related pulls + } else if err = pull_service.CloseBranchPulls(pusher, repo.ID, branch); err != nil { + log.Error("close related pull request failed: %v", err) + } if err = models.WatchIfAuto(opts.PusherID, repo.ID, true); err != nil { log.Warn("Fail to perform auto watch on user %v for repo %v: %v", opts.PusherID, repo.ID, err) @@ -544,11 +553,14 @@ func PushUpdates(repo *models.Repository, optsList []*PushUpdateOptions) error { if err = models.RemoveDeletedBranch(repo.ID, opts.Branch); err != nil { log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, opts.Branch, err) } - } - log.Trace("TriggerTask '%s/%s' by %s", repo.Name, opts.Branch, pusher.Name) + log.Trace("TriggerTask '%s/%s' by %s", repo.Name, opts.Branch, pusher.Name) - go pull_service.AddTestPullRequestTask(pusher, repo.ID, opts.Branch, true, opts.OldCommitID, opts.NewCommitID) + go pull_service.AddTestPullRequestTask(pusher, repo.ID, opts.Branch, true, opts.OldCommitID, opts.NewCommitID) + // close all related pulls + } else if err = pull_service.CloseBranchPulls(pusher, repo.ID, opts.Branch); err != nil { + log.Error("close related pull request failed: %v", err) + } if err = models.WatchIfAuto(opts.PusherID, repo.ID, true); err != nil { log.Warn("Fail to perform auto watch on user %v for repo %v: %v", opts.PusherID, repo.ID, err) |