|
|
@ -1051,6 +1051,17 @@ func MergePullRequest(ctx *context.Context) { |
|
|
|
log.Trace("Pull request merged: %d", pr.ID) |
|
|
|
log.Trace("Pull request merged: %d", pr.ID) |
|
|
|
|
|
|
|
|
|
|
|
if form.DeleteBranchAfterMerge { |
|
|
|
if form.DeleteBranchAfterMerge { |
|
|
|
|
|
|
|
// Don't cleanup when other pr use this branch as head branch
|
|
|
|
|
|
|
|
exist, err := models.HasUnmergedPullRequestsByHeadInfo(pr.HeadRepoID, pr.HeadBranch) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.ServerError("HasUnmergedPullRequestsByHeadInfo", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if exist { |
|
|
|
|
|
|
|
ctx.Redirect(issue.Link()) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var headRepo *git.Repository |
|
|
|
var headRepo *git.Repository |
|
|
|
if ctx.Repo != nil && ctx.Repo.Repository != nil && pr.HeadRepoID == ctx.Repo.Repository.ID && ctx.Repo.GitRepo != nil { |
|
|
|
if ctx.Repo != nil && ctx.Repo.Repository != nil && pr.HeadRepoID == ctx.Repo.Repository.ID && ctx.Repo.GitRepo != nil { |
|
|
|
headRepo = ctx.Repo.GitRepo |
|
|
|
headRepo = ctx.Repo.GitRepo |
|
|
@ -1222,6 +1233,17 @@ func CleanUpPullRequest(ctx *context.Context) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Don't cleanup when there are other PR's that use this branch as head branch.
|
|
|
|
|
|
|
|
exist, err := models.HasUnmergedPullRequestsByHeadInfo(pr.HeadRepoID, pr.HeadBranch) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.ServerError("HasUnmergedPullRequestsByHeadInfo", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if exist { |
|
|
|
|
|
|
|
ctx.NotFound("CleanUpPullRequest", nil) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := pr.LoadHeadRepo(); err != nil { |
|
|
|
if err := pr.LoadHeadRepo(); err != nil { |
|
|
|
ctx.ServerError("LoadHeadRepo", err) |
|
|
|
ctx.ServerError("LoadHeadRepo", err) |
|
|
|
return |
|
|
|
return |
|
|
|