Backport #31219 by @lunny Fix #31135 Before <img width="527" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/60c07b55-3db2-4a9a-98f1-0eb72d149df2"> After <img width="664" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/0670ff5d-9e0b-47ac-aba4-9db9131de3b3"> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@ -1791,6 +1791,7 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
pull.Issue = issue
|
pull.Issue = issue
|
||||||
canDelete := false
|
canDelete := false
|
||||||
allowMerge := false
|
allowMerge := false
|
||||||
|
canWriteToHeadRepo := false
|
||||||
|
|
||||||
if ctx.IsSigned {
|
if ctx.IsSigned {
|
||||||
if err := pull.LoadHeadRepo(ctx); err != nil {
|
if err := pull.LoadHeadRepo(ctx); err != nil {
|
||||||
@ -1811,7 +1812,7 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
ctx.Data["DeleteBranchLink"] = issue.Link() + "/cleanup"
|
ctx.Data["DeleteBranchLink"] = issue.Link() + "/cleanup"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.Data["CanWriteToHeadRepo"] = true
|
canWriteToHeadRepo = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1823,6 +1824,9 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
ctx.ServerError("GetUserRepoPermission", err)
|
ctx.ServerError("GetUserRepoPermission", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if !canWriteToHeadRepo { // maintainers maybe allowed to push to head repo even if they can't write to it
|
||||||
|
canWriteToHeadRepo = pull.AllowMaintainerEdit && perm.CanWrite(unit.TypeCode)
|
||||||
|
}
|
||||||
allowMerge, err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
|
allowMerge, err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("IsUserAllowedToMerge", err)
|
ctx.ServerError("IsUserAllowedToMerge", err)
|
||||||
@ -1835,6 +1839,8 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["CanWriteToHeadRepo"] = canWriteToHeadRepo
|
||||||
|
ctx.Data["ShowMergeInstructions"] = canWriteToHeadRepo
|
||||||
ctx.Data["AllowMerge"] = allowMerge
|
ctx.Data["AllowMerge"] = allowMerge
|
||||||
|
|
||||||
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
|
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
|
||||||
@ -1889,13 +1895,9 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
ctx.ServerError("LoadProtectedBranch", err)
|
ctx.ServerError("LoadProtectedBranch", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["ShowMergeInstructions"] = true
|
|
||||||
if pb != nil {
|
if pb != nil {
|
||||||
pb.Repo = pull.BaseRepo
|
pb.Repo = pull.BaseRepo
|
||||||
var showMergeInstructions bool
|
|
||||||
if ctx.Doer != nil {
|
|
||||||
showMergeInstructions = pb.CanUserPush(ctx, ctx.Doer)
|
|
||||||
}
|
|
||||||
ctx.Data["ProtectedBranch"] = pb
|
ctx.Data["ProtectedBranch"] = pb
|
||||||
ctx.Data["IsBlockedByApprovals"] = !issues_model.HasEnoughApprovals(ctx, pb, pull)
|
ctx.Data["IsBlockedByApprovals"] = !issues_model.HasEnoughApprovals(ctx, pb, pull)
|
||||||
ctx.Data["IsBlockedByRejection"] = issues_model.MergeBlockedByRejectedReview(ctx, pb, pull)
|
ctx.Data["IsBlockedByRejection"] = issues_model.MergeBlockedByRejectedReview(ctx, pb, pull)
|
||||||
@ -1906,7 +1908,6 @@ func ViewIssue(ctx *context.Context) {
|
|||||||
ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles
|
ctx.Data["ChangedProtectedFiles"] = pull.ChangedProtectedFiles
|
||||||
ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0
|
ctx.Data["IsBlockedByChangedProtectedFiles"] = len(pull.ChangedProtectedFiles) != 0
|
||||||
ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles)
|
ctx.Data["ChangedProtectedFilesNum"] = len(pull.ChangedProtectedFiles)
|
||||||
ctx.Data["ShowMergeInstructions"] = showMergeInstructions
|
|
||||||
}
|
}
|
||||||
ctx.Data["WillSign"] = false
|
ctx.Data["WillSign"] = false
|
||||||
if ctx.Doer != nil {
|
if ctx.Doer != nil {
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
<div class="ui secondary segment">
|
<div class="ui secondary segment">
|
||||||
{{if eq .PullRequest.Flow 0}}
|
{{if eq .PullRequest.Flow 0}}
|
||||||
<div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></origin-url>{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div>
|
<div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></origin-url>{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div>
|
||||||
<div>git checkout {{$localBranch}}</div>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<div>git fetch -u origin {{.GetGitRefName}}:{{$localBranch}}</div>
|
<div>git fetch -u origin {{.PullRequest.GetGitRefName}}:{{$localBranch}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<div>git checkout {{$localBranch}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{if .ShowMergeInstructions}}
|
{{if .ShowMergeInstructions}}
|
||||||
<div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}}</div>
|
<div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}}</div>
|
||||||
|
Reference in New Issue
Block a user