aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
authoryp053272023-02-25 01:56:41 +0900
committerGitHub2023-02-24 16:56:41 +0000
commit9eb61b77acecfb8702dfee287690c4b7329e60fc (patch)
tree4359f3ef3c6d3d29ea9d53d4aac4d2a32454e279 /routers
parente77528baed9bcb8100047280515e5af6656680f3 (diff)
Redirect to the commit page after applying patch (#23056)
Fixes https://github.com/go-gitea/gitea/issues/22621
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/patch.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go
index 0ffec0c4e..efb466249 100644
--- a/routers/web/repo/patch.go
+++ b/routers/web/repo/patch.go
@@ -27,8 +27,6 @@ func NewDiffPatch(ctx *context.Context) {
ctx.Data["PageIsPatch"] = true
- ctx.Data["TreePath"] = ""
-
ctx.Data["commit_summary"] = ""
ctx.Data["commit_message"] = ""
if canCommit {
@@ -54,7 +52,6 @@ func NewDiffPatchPost(ctx *context.Context) {
branchName = form.NewBranchName
}
ctx.Data["PageIsPatch"] = true
- ctx.Data["TreePath"] = ""
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
ctx.Data["FileContent"] = form.Content
ctx.Data["commit_summary"] = form.CommitSummary
@@ -89,13 +86,14 @@ func NewDiffPatchPost(ctx *context.Context) {
message += "\n\n" + form.CommitMessage
}
- if _, err := files.ApplyDiffPatch(ctx, ctx.Repo.Repository, ctx.Doer, &files.ApplyDiffPatchOptions{
+ fileResponse, err := files.ApplyDiffPatch(ctx, ctx.Repo.Repository, ctx.Doer, &files.ApplyDiffPatchOptions{
LastCommitID: form.LastCommit,
OldBranch: ctx.Repo.BranchName,
NewBranch: branchName,
Message: message,
Content: strings.ReplaceAll(form.Content, "\r", ""),
- }); err != nil {
+ })
+ if err != nil {
if models.IsErrBranchAlreadyExists(err) {
// User has specified a branch that already exists
branchErr := err.(models.ErrBranchAlreadyExists)
@@ -114,6 +112,6 @@ func NewDiffPatchPost(ctx *context.Context) {
if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(ctx, unit.TypePullRequests) {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName))
} else {
- ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(branchName) + "/" + util.PathEscapeSegments(form.TreePath))
+ ctx.Redirect(ctx.Repo.RepoLink + "/commit/" + fileResponse.Commit.SHA)
}
}