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