aboutsummaryrefslogtreecommitdiff
path: root/routers/repo/editor.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-23 13:05:29 -0500
committerUnknwon <u@gogs.io>2017-02-23 13:05:29 -0500
commit5ec21d56ef2a002327b705ede5adabe3f1f13f34 (patch)
tree75197d9597dc881ba819e8d8fb21416b082005bd /routers/repo/editor.go
parent266c8f5a85d259d1e997985062c924630625fc71 (diff)
editor: fix cannot redirect to correct pull request URL
Was only possible to correctly redirect to pull request page within same repository. And didn't take care of case when upstream has disabled pull request. Also add a new method 'PullRequestURL' to unify the code.
Diffstat (limited to 'routers/repo/editor.go')
-rw-r--r--routers/repo/editor.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go
index 326a8c7e..83302039 100644
--- a/routers/repo/editor.go
+++ b/routers/repo/editor.go
@@ -279,8 +279,8 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
return
}
- if form.IsNewBrnach() {
- ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ if form.IsNewBrnach() && ctx.Repo.PullRequest.Allowed {
+ ctx.Redirect(ctx.Repo.PullRequestURL(oldBranchName, form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + template.EscapePound(form.TreePath))
}
@@ -382,8 +382,8 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
return
}
- if form.IsNewBrnach() {
- ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ if form.IsNewBrnach() && ctx.Repo.PullRequest.Allowed {
+ ctx.Redirect(ctx.Repo.PullRequestURL(oldBranchName, form.NewBranchName))
} else {
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.TreePath))
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
@@ -503,8 +503,8 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
return
}
- if form.IsNewBrnach() {
- ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ if form.IsNewBrnach() && ctx.Repo.PullRequest.Allowed {
+ ctx.Redirect(ctx.Repo.PullRequestURL(oldBranchName, form.NewBranchName))
} else {
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + form.TreePath)
}