@@ -27,8 +27,6 @@ func NewDiffPatch(ctx *context.Context) {
27
27
28
28
ctx .Data ["PageIsPatch" ] = true
29
29
30
- ctx .Data ["TreePath" ] = ""
31
-
32
30
ctx .Data ["commit_summary" ] = ""
33
31
ctx .Data ["commit_message" ] = ""
34
32
if canCommit {
@@ -54,7 +52,6 @@ func NewDiffPatchPost(ctx *context.Context) {
54
52
branchName = form .NewBranchName
55
53
}
56
54
ctx .Data ["PageIsPatch" ] = true
57
- ctx .Data ["TreePath" ] = ""
58
55
ctx .Data ["BranchLink" ] = ctx .Repo .RepoLink + "/src/" + ctx .Repo .BranchNameSubURL ()
59
56
ctx .Data ["FileContent" ] = form .Content
60
57
ctx .Data ["commit_summary" ] = form .CommitSummary
@@ -89,13 +86,14 @@ func NewDiffPatchPost(ctx *context.Context) {
89
86
message += "\n \n " + form .CommitMessage
90
87
}
91
88
92
- if _ , err := files .ApplyDiffPatch (ctx , ctx .Repo .Repository , ctx .Doer , & files.ApplyDiffPatchOptions {
89
+ fileResponse , err := files .ApplyDiffPatch (ctx , ctx .Repo .Repository , ctx .Doer , & files.ApplyDiffPatchOptions {
93
90
LastCommitID : form .LastCommit ,
94
91
OldBranch : ctx .Repo .BranchName ,
95
92
NewBranch : branchName ,
96
93
Message : message ,
97
94
Content : strings .ReplaceAll (form .Content , "\r " , "" ),
98
- }); err != nil {
95
+ })
96
+ if err != nil {
99
97
if models .IsErrBranchAlreadyExists (err ) {
100
98
// User has specified a branch that already exists
101
99
branchErr := err .(models.ErrBranchAlreadyExists )
@@ -114,6 +112,6 @@ func NewDiffPatchPost(ctx *context.Context) {
114
112
if form .CommitChoice == frmCommitChoiceNewBranch && ctx .Repo .Repository .UnitEnabled (ctx , unit .TypePullRequests ) {
115
113
ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + util .PathEscapeSegments (ctx .Repo .BranchName ) + "..." + util .PathEscapeSegments (form .NewBranchName ))
116
114
} else {
117
- ctx .Redirect (ctx .Repo .RepoLink + "/src/branch/ " + util . PathEscapeSegments ( branchName ) + "/" + util . PathEscapeSegments ( form . TreePath ) )
115
+ ctx .Redirect (ctx .Repo .RepoLink + "/commit/ " + fileResponse . Commit . SHA )
118
116
}
119
117
}
0 commit comments