@@ -53,6 +53,7 @@ func renderCommitRights(ctx *context.Context) bool {
5353 }
5454 ctx .Data ["CanCommitToBranch" ] = canCommitToBranch
5555 ctx .Data ["CanCreatePullRequest" ] = ctx .Repo .Repository .UnitEnabled (ctx , unit .TypePullRequests ) || canCreateBasePullRequest (ctx )
56+ ctx .Data ["IsForkDefaultBranch" ] = canCreateBasePullRequest (ctx ) && ctx .Repo .BranchName == ctx .Repo .Repository .BaseRepo .DefaultBranch
5657
5758 return canCommitToBranch .CanCommitToBranch
5859}
@@ -62,13 +63,13 @@ func redirectToPullRequest(ctx *context.Context, newBranchName string) bool {
6263 repo := ctx .Repo .Repository
6364 baseBranch := util .PathEscapeSegments (ctx .Repo .BranchName )
6465 headBranch := util .PathEscapeSegments (newBranchName )
65- if ! repo .UnitEnabled (ctx , unit .TypePullRequests ) {
66- if ! canCreateBasePullRequest (ctx ) {
67- return false
68- }
66+ if repo .UnitEnabled (ctx , unit .TypePullRequests ) {
67+ } else if canCreateBasePullRequest (ctx ) {
6968 baseBranch = util .PathEscapeSegments (repo .BaseRepo .DefaultBranch )
7069 headBranch = util .PathEscapeSegments (repo .Owner .Name ) + "/" + util .PathEscapeSegments (repo .Name ) + ":" + headBranch
7170 repo = repo .BaseRepo
71+ } else {
72+ return false
7273 }
7374 ctx .Redirect (repo .Link () + "/compare/" + baseBranch + "..." + headBranch )
7475 return true
@@ -172,7 +173,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
172173 ctx .Data ["BranchLink" ] = ctx .Repo .RepoLink + "/src/" + ctx .Repo .BranchNameSubURL ()
173174 ctx .Data ["commit_summary" ] = ""
174175 ctx .Data ["commit_message" ] = ""
175- if canCommit {
176+ if canCommit && ! canCreateBasePullRequest ( ctx ) {
176177 ctx .Data ["commit_choice" ] = frmCommitChoiceDirect
177178 } else {
178179 ctx .Data ["commit_choice" ] = frmCommitChoiceNewBranch
@@ -421,7 +422,7 @@ func DeleteFile(ctx *context.Context) {
421422 ctx .Data ["commit_summary" ] = ""
422423 ctx .Data ["commit_message" ] = ""
423424 ctx .Data ["last_commit" ] = ctx .Repo .CommitID
424- if canCommit {
425+ if canCommit && ! canCreateBasePullRequest ( ctx ) {
425426 ctx .Data ["commit_choice" ] = frmCommitChoiceDirect
426427 } else {
427428 ctx .Data ["commit_choice" ] = frmCommitChoiceNewBranch
@@ -581,7 +582,7 @@ func UploadFile(ctx *context.Context) {
581582 ctx .Data ["BranchLink" ] = ctx .Repo .RepoLink + "/src/" + ctx .Repo .BranchNameSubURL ()
582583 ctx .Data ["commit_summary" ] = ""
583584 ctx .Data ["commit_message" ] = ""
584- if canCommit {
585+ if canCommit && ! canCreateBasePullRequest ( ctx ) {
585586 ctx .Data ["commit_choice" ] = frmCommitChoiceDirect
586587 } else {
587588 ctx .Data ["commit_choice" ] = frmCommitChoiceNewBranch
0 commit comments