Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On merge of already closed PR redirect back to the pulls page #10010

Merged
merged 6 commits into from
Jan 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More redirects
  • Loading branch information
zeripath committed Jan 27, 2020
commit 52bb1f02c78806bce67d5da1e26758ada9800ce3
22 changes: 17 additions & 5 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,12 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
return
}
if issue.IsClosed {
ctx.Flash.Error(ctx.Tr("repo.pulls.is_closed"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls" + com.ToStr(issue.Index))
if issue.IsPull {
ctx.Flash.Error(ctx.Tr("repo.pulls.is_closed"))
} else {
ctx.Flash.Error(ctx.Tr("repo.issues.closed_title"))
}
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
zeripath marked this conversation as resolved.
Show resolved Hide resolved
zeripath marked this conversation as resolved.
Show resolved Hide resolved
return
}

Expand All @@ -692,12 +696,20 @@ func MergePullRequest(ctx *context.Context, form auth.MergePullRequestForm) {
return
}
if !allowedMerge {
ctx.NotFound("MergePullRequest", nil)
ctx.Flash.Error(ctx.Tr("repo.pulls.update_not_allowed"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
return
}

if !pr.CanAutoMerge() || pr.HasMerged {
ctx.NotFound("MergePullRequest", nil)
if !pr.CanAutoMerge() {
ctx.Flash.Error(ctx.Tr("repo.pulls.no_merge_not_ready"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
return
}

if pr.HasMerged {
ctx.Flash.Error(ctx.Tr("repo.pulls.has_merged"))
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(issue.Index))
return
}

Expand Down