mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Prevent merge of outdated PRs on protected branches (#11012)
* Block PR on Outdated Branch * finalize * cleanup * fix typo and sentences thanks @guillep2k Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
{{- else if .IsPullRequestBroken}}red
|
||||
{{- else if .IsBlockedByApprovals}}red
|
||||
{{- else if .IsBlockedByRejection}}red
|
||||
{{- else if .IsBlockedByOutdatedBranch}}red
|
||||
{{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
|
||||
{{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
|
||||
{{- else if and .RequireSigned (not .WillSign)}}}red
|
||||
@@ -138,6 +139,11 @@
|
||||
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
||||
{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
|
||||
</div>
|
||||
{{else if .IsBlockedByOutdatedBranch}}
|
||||
<div class="item text red">
|
||||
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
||||
{{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
||||
</div>
|
||||
{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
|
||||
<div class="item text red">
|
||||
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
||||
@@ -158,7 +164,7 @@
|
||||
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
|
||||
</div>
|
||||
{{end}}
|
||||
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
|
||||
{{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOutdatedBranch (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
|
||||
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
|
||||
{{if $notAllOverridableChecksOk}}
|
||||
<div class="item text yellow">
|
||||
@@ -342,6 +348,11 @@
|
||||
{{svg "octicon-x" 16}}
|
||||
{{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
|
||||
</div>
|
||||
{{else if .IsBlockedByOutdatedBranch}}
|
||||
<div class="item text red">
|
||||
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
|
||||
{{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
|
||||
</div>
|
||||
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
|
||||
<div class="item text red">
|
||||
{{svg "octicon-x" 16}}
|
||||
|
@@ -225,6 +225,13 @@
|
||||
<p class="help">{{.i18n.Tr "repo.settings.require_signed_commits_desc"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input name="block_on_outdated_branch" type="checkbox" {{if .Branch.BlockOnOutdatedBranch}}checked{{end}}>
|
||||
<label for="block_on_outdated_branch">{{.i18n.Tr "repo.settings.block_outdated_branch"}}</label>
|
||||
<p class="help">{{.i18n.Tr "repo.settings.block_outdated_branch_desc"}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="protected_file_patterns">{{.i18n.Tr "repo.settings.protect_protected_file_patterns"}}</label>
|
||||
<input name="protected_file_patterns" id="protected_file_patterns" type="text" value="{{.Branch.ProtectedFilePatterns}}">
|
||||
|
@@ -10072,6 +10072,10 @@
|
||||
},
|
||||
"x-go-name": "ApprovalsWhitelistUsernames"
|
||||
},
|
||||
"block_on_outdated_branch": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnOutdatedBranch"
|
||||
},
|
||||
"block_on_rejected_reviews": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnRejectedReviews"
|
||||
@@ -10392,6 +10396,10 @@
|
||||
},
|
||||
"x-go-name": "ApprovalsWhitelistUsernames"
|
||||
},
|
||||
"block_on_outdated_branch": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnOutdatedBranch"
|
||||
},
|
||||
"block_on_rejected_reviews": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnRejectedReviews"
|
||||
@@ -11204,6 +11212,10 @@
|
||||
},
|
||||
"x-go-name": "ApprovalsWhitelistUsernames"
|
||||
},
|
||||
"block_on_outdated_branch": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnOutdatedBranch"
|
||||
},
|
||||
"block_on_rejected_reviews": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "BlockOnRejectedReviews"
|
||||
|
Reference in New Issue
Block a user