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 /routers/repo | |
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 'routers/repo')
-rw-r--r-- | routers/repo/pull.go | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c84174783a..655be2e82e 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -343,19 +343,6 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare setMergeTarget(ctx, pull) - divergence, err := pull_service.GetDiverging(pull) - if err != nil { - ctx.ServerError("GetDiverging", err) - return nil - } - ctx.Data["Divergence"] = divergence - allowUpdate, err := pull_service.IsUserAllowedToUpdate(pull, ctx.User) - if err != nil { - ctx.ServerError("IsUserAllowedToUpdate", err) - return nil - } - ctx.Data["UpdateAllowed"] = allowUpdate - if err := pull.LoadProtectedBranch(); err != nil { ctx.ServerError("LoadProtectedBranch", err) return nil @@ -392,6 +379,22 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare } } + if headBranchExist { + allowUpdate, err := pull_service.IsUserAllowedToUpdate(pull, ctx.User) + if err != nil { + ctx.ServerError("IsUserAllowedToUpdate", err) + return nil + } + ctx.Data["UpdateAllowed"] = allowUpdate + + divergence, err := pull_service.GetDiverging(pull) + if err != nil { + ctx.ServerError("GetDiverging", err) + return nil + } + ctx.Data["Divergence"] = divergence + } + sha, err := baseGitRepo.GetRefCommitID(pull.GetGitRefName()) if err != nil { ctx.ServerError(fmt.Sprintf("GetRefCommitID(%s)", pull.GetGitRefName()), err) |