{{if and .Issue.PullRequest.HasMerged (not .IsPullBranchDeletable)}} {{/* Then the merge box will not be displayed because this page already contains enough information */}} {{else}}
{{svg "octicon-git-merge" 40}}
{{template "repo/pulls/status" .}} {{$showGeneralMergeForm := false}}
{{if .Issue.PullRequest.HasMerged}} {{if .IsPullBranchDeletable}}

{{ctx.Locale.Tr "repo.pulls.merged_success"}}

{{end}} {{else if .Issue.IsClosed}}

{{ctx.Locale.Tr "repo.pulls.closed"}}

{{if and .IsPullBranchDeletable (not .IsPullRequestBroken)}}
{{end}}
{{else if .IsPullFilesConflicted}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.files_conflicted"}}
    {{range .ConflictedFiles}}
  • {{.}}
  • {{end}}
{{else if .IsPullRequestBroken}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.data_broken"}}
{{else if .IsPullWorkInProgress}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.cannot_merge_work_in_progress"}}
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}} {{end}}
{{template "repo/issue/view_content/update_branch_by_merge" $}} {{else if .Issue.PullRequest.IsChecking}}
{{svg "octicon-sync"}} {{ctx.Locale.Tr "repo.pulls.is_checking"}}
{{else if .Issue.PullRequest.IsAncestor}}
{{svg "octicon-alert"}} {{ctx.Locale.Tr "repo.pulls.is_ancestor"}}
{{else if or .Issue.PullRequest.CanAutoMerge .Issue.PullRequest.IsEmpty}} {{if .IsBlockedByApprovals}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
{{else if .IsBlockedByRejection}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}}
{{else if .IsBlockedByOfficialReviewRequests}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
{{else if .IsBlockedByOutdatedBranch}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
{{else if .IsBlockedByChangedProtectedFiles}}
{{svg "octicon-x"}} {{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
    {{range .ChangedProtectedFiles}}
  • {{.}}
  • {{end}}
{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}}
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.required_status_check_missing"}}
{{else if and .AllowMerge .RequireSigned (not .WillSign)}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}}
{{svg "octicon-unlock"}} {{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
{{end}} {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOfficialReviewRequests .IsBlockedByOutdatedBranch .IsBlockedByChangedProtectedFiles (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}} {{/* admin can merge without checks, writer can merge when checks succeed */}} {{$canMergeNow := and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}} {{/* admin and writer both can make an auto merge schedule */}} {{if $canMergeNow}} {{if $notAllOverridableChecksOk}}
{{svg "octicon-dot-fill"}} {{ctx.Locale.Tr "repo.pulls.required_status_check_administrator"}}
{{else}}
{{svg "octicon-check"}} {{ctx.Locale.Tr "repo.pulls.can_auto_merge_desc"}}
{{end}} {{if .WillSign}}
{{svg "octicon-lock" 16 "text green"}} {{ctx.Locale.Tr "repo.signing.will_sign" .SigningKey}}
{{else if .IsSigned}}
{{svg "octicon-unlock"}} {{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}}
{{end}} {{end}} {{template "repo/issue/view_content/update_branch_by_merge" $}} {{if .Issue.PullRequest.IsEmpty}}
{{svg "octicon-alert"}} {{ctx.Locale.Tr "repo.pulls.is_empty"}}
{{end}} {{if .AllowMerge}} {{/* user is allowed to merge */}} {{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}} {{$approvers := .Issue.PullRequest.GetApprovers}} {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}} {{$hasPendingPullRequestMergeTip := ""}} {{if .HasPendingPullRequestMerge}} {{$createdPRMergeStr := TimeSinceUnix .PendingPullRequestMerge.CreatedUnix $.locale}} {{$hasPendingPullRequestMergeTip = ctx.Locale.Tr "repo.pulls.auto_merge_has_pending_schedule" .PendingPullRequestMerge.Doer.Name $createdPRMergeStr}} {{end}}
{{$showGeneralMergeForm = true}}
{{else}} {{/* no merge style was set in repo setting: not or ($prUnit.PullRequestsConfig.AllowMerge ...) */}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.no_merge_desc"}}
{{svg "octicon-info"}} {{ctx.Locale.Tr "repo.pulls.no_merge_helper"}}
{{end}} {{/* end if the repo was set to use any merge style */}} {{else}} {{/* user is not allowed to merge */}}
{{svg "octicon-info"}} {{ctx.Locale.Tr "repo.pulls.no_merge_access"}}
{{end}} {{/* end if user is allowed to merge or not */}} {{else}} {{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}} {{if .IsBlockedByApprovals}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}}
{{else if .IsBlockedByRejection}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}}
{{else if .IsBlockedByOfficialReviewRequests}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}}
{{else if .IsBlockedByOutdatedBranch}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}}
{{else if .IsBlockedByChangedProtectedFiles}}
{{svg "octicon-x"}} {{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
    {{range .ChangedProtectedFiles}}
  • {{.}}
  • {{end}}
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}}
{{else if and .RequireSigned (not .WillSign)}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}}
{{else}}
{{svg "octicon-x"}} {{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_desc"}}
{{svg "octicon-info"}} {{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_helper"}}
{{end}} {{end}}{{/* end if: pull request status */}} {{/* Manually Merged is not a well-known feature, it helps repo admins to mark a non-mergeable PR (already merged, conflicted) as merged To test it: * Enable "Manually Merged" feature in the Repository Settings * Create a pull request, either: * - Merge the pull request branch locally and push the merged commit to Gitea * - Make some conflicts between the base branch and the pull request branch * Then the Manually Merged form will be shown to repo admin users */}} {{if and $.StillCanManualMerge (not $showGeneralMergeForm)}}
{{.CsrfTokenHtml}}
{{end}} {{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}} {{template "repo/issue/view_content/pull_merge_instruction" .Issue.PullRequest}} {{end}}
{{end}}