aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-02-20 22:29:15 -0500
committerUnknwon <u@gogs.io>2017-02-20 22:29:15 -0500
commit5895d435747c75f17d0bbb9ec244e9ab883dabb6 (patch)
tree2d04a895aabdd4226c80343ae5dee2b8e8b30fe5 /routers
parente78f2527134d2324c3a3047b0ef2a919297d70dd (diff)
editor: redirect to new pull request page after create new branch
Diffstat (limited to 'routers')
1 files changed, 19 insertions, 7 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go
index 22e36d96..326a8c7e 100644
--- a/routers/repo/editor.go
+++ b/routers/repo/editor.go
@@ -135,7 +135,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
lastCommit := form.LastCommit
form.LastCommit = ctx.Repo.Commit.ID.String()
- if form.CommitChoice == "commit-to-new-branch" {
+ if form.IsNewBrnach() {
branchName = form.NewBranchName
}
@@ -279,7 +279,11 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
return
}
- ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + template.EscapePound(form.TreePath))
+ if form.IsNewBrnach() {
+ ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ } else {
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + template.EscapePound(form.TreePath))
+ }
}
func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
@@ -336,7 +340,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
oldBranchName := ctx.Repo.BranchName
branchName := oldBranchName
- if form.CommitChoice == "commit-to-new-branch" {
+ if form.IsNewBrnach() {
branchName = form.NewBranchName
}
ctx.Data["commit_summary"] = form.CommitSummary
@@ -378,8 +382,12 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
return
}
- ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.TreePath))
- ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
+ if form.IsNewBrnach() {
+ ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ } else {
+ ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", ctx.Repo.TreePath))
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
+ }
}
func renderUploadSettings(ctx *context.Context) {
@@ -417,7 +425,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
oldBranchName := ctx.Repo.BranchName
branchName := oldBranchName
- if form.CommitChoice == "commit-to-new-branch" {
+ if form.IsNewBrnach() {
branchName = form.NewBranchName
}
@@ -495,7 +503,11 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
return
}
- ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + form.TreePath)
+ if form.IsNewBrnach() {
+ ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + oldBranchName + "..." + form.NewBranchName)
+ } else {
+ ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + form.TreePath)
+ }
}
func UploadFileToServer(ctx *context.Context) {