A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

453 lines
19 KiB

[Enhancement] Allow admin to merge pr with protected file changes (#12078) * [Enhancement] Allow admin to merge pr with protected file changes As tilte, show protected message in diff page and merge box. Signed-off-by: a1012112796 <1012112796@qq.com> * remove unused ver * Update options/locale/locale_en-US.ini Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> * Add TrN * Apply suggestions from code review * fix lint * Update options/locale/locale_en-US.ini Co-authored-by: zeripath <art27@cantab.net> * Apply suggestions from code review * move pr proteced files check to TestPatch * Call TestPatch when protected branches settings changed * Apply review suggestion @CirnoT * move to service @lunny * slightly restructure routers/private/hook.go Adds a lot of comments and simplifies the logic Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * skip duplicate protected files check * fix check logic * slight refactor of TestPatch Signed-off-by: Andrew Thornton <art27@cantab.net> * When checking for protected files changes in TestPatch use the temporary repository Signed-off-by: Andrew Thornton <art27@cantab.net> * fix introduced issue with hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove the check on PR index being greater than 0 as it unnecessary Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
[Enhancement] Allow admin to merge pr with protected file changes (#12078) * [Enhancement] Allow admin to merge pr with protected file changes As tilte, show protected message in diff page and merge box. Signed-off-by: a1012112796 <1012112796@qq.com> * remove unused ver * Update options/locale/locale_en-US.ini Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> * Add TrN * Apply suggestions from code review * fix lint * Update options/locale/locale_en-US.ini Co-authored-by: zeripath <art27@cantab.net> * Apply suggestions from code review * move pr proteced files check to TestPatch * Call TestPatch when protected branches settings changed * Apply review suggestion @CirnoT * move to service @lunny * slightly restructure routers/private/hook.go Adds a lot of comments and simplifies the logic Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * skip duplicate protected files check * fix check logic * slight refactor of TestPatch Signed-off-by: Andrew Thornton <art27@cantab.net> * When checking for protected files changes in TestPatch use the temporary repository Signed-off-by: Andrew Thornton <art27@cantab.net> * fix introduced issue with hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove the check on PR index being greater than 0 as it unnecessary Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
[Enhancement] Allow admin to merge pr with protected file changes (#12078) * [Enhancement] Allow admin to merge pr with protected file changes As tilte, show protected message in diff page and merge box. Signed-off-by: a1012112796 <1012112796@qq.com> * remove unused ver * Update options/locale/locale_en-US.ini Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> * Add TrN * Apply suggestions from code review * fix lint * Update options/locale/locale_en-US.ini Co-authored-by: zeripath <art27@cantab.net> * Apply suggestions from code review * move pr proteced files check to TestPatch * Call TestPatch when protected branches settings changed * Apply review suggestion @CirnoT * move to service @lunny * slightly restructure routers/private/hook.go Adds a lot of comments and simplifies the logic Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * skip duplicate protected files check * fix check logic * slight refactor of TestPatch Signed-off-by: Andrew Thornton <art27@cantab.net> * When checking for protected files changes in TestPatch use the temporary repository Signed-off-by: Andrew Thornton <art27@cantab.net> * fix introduced issue with hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove the check on PR index being greater than 0 as it unnecessary Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
[Enhancement] Allow admin to merge pr with protected file changes (#12078) * [Enhancement] Allow admin to merge pr with protected file changes As tilte, show protected message in diff page and merge box. Signed-off-by: a1012112796 <1012112796@qq.com> * remove unused ver * Update options/locale/locale_en-US.ini Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> * Add TrN * Apply suggestions from code review * fix lint * Update options/locale/locale_en-US.ini Co-authored-by: zeripath <art27@cantab.net> * Apply suggestions from code review * move pr proteced files check to TestPatch * Call TestPatch when protected branches settings changed * Apply review suggestion @CirnoT * move to service @lunny * slightly restructure routers/private/hook.go Adds a lot of comments and simplifies the logic Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * skip duplicate protected files check * fix check logic * slight refactor of TestPatch Signed-off-by: Andrew Thornton <art27@cantab.net> * When checking for protected files changes in TestPatch use the temporary repository Signed-off-by: Andrew Thornton <art27@cantab.net> * fix introduced issue with hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove the check on PR index being greater than 0 as it unnecessary Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
  1. {{if or .PullReviewers .OriginalReviews }}
  2. <div class="comment box">
  3. <div class="content">
  4. <div class="ui segment">
  5. <h4>{{$.i18n.Tr "repo.issues.review.reviewers"}}</h4>
  6. {{range .PullReviewers}}
  7. {{ $createdStr:= TimeSinceUnix .Review.UpdatedUnix $.Lang }}
  8. <div class="ui divider"></div>
  9. <div class="review-item">
  10. <div class="review-item-left">
  11. {{if .User}}
  12. <a href="{{.User.HomeLink}}">
  13. {{avatar .User}}
  14. </a>
  15. {{end}}
  16. <span class="text grey">
  17. {{if .User}}
  18. <a href="{{.User.HomeLink}}">{{.User.GetDisplayName}}</a>
  19. {{else if .Team}}
  20. <span class="ui text">{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}</span>
  21. {{end}}
  22. {{if eq .Review.Type 1}}
  23. {{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
  24. {{else if eq .Review.Type 2}}
  25. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  26. {{else if eq .Review.Type 3}}
  27. {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
  28. {{else if eq .Review.Type 4}}
  29. {{$.i18n.Tr "repo.issues.review.wait" $createdStr | Safe}}
  30. {{else}}
  31. {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
  32. {{end}}
  33. </span>
  34. </div>
  35. <div class="review-item-right">
  36. {{if .Review.Stale}}
  37. <span class="ui poping up type-icon text grey" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
  38. <i class="octicon icon fa-hourglass-end"></i>
  39. </span>
  40. {{end}}
  41. <span class="type-icon text {{if eq .Review.Type 1}}green
  42. {{- else if eq .Review.Type 2}}grey
  43. {{- else if eq .Review.Type 3}}red
  44. {{- else if eq .Review.Type 4}}yellow
  45. {{else}}grey{{end}}">
  46. {{if .CanChange }}
  47. <a href="#" class="ui poping up icon re-request-review {{if .Checked}}checked{{end}}" data-issue-id="{{$.Issue.ID}}" data-content="{{if .Checked}} {{$.i18n.Tr "repo.issues.remove_request_review"}} {{else}} {{$.i18n.Tr "repo.issues.re_request_review"}} {{end}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">
  48. {{if .Checked}} {{svg "octicon-trashcan"}} {{else}} {{svg "octicon-sync"}} {{end}}
  49. </a>
  50. {{end}}
  51. {{svg (printf "octicon-%s" .Review.Type.Icon)}}
  52. </span>
  53. </div>
  54. </div>
  55. {{end}}
  56. {{range .OriginalReviews}}
  57. {{ $createdStr:= TimeSinceUnix .UpdatedUnix $.Lang }}
  58. <div class="ui divider"></div>
  59. <div class="review-item">
  60. <div class="review-item-left">
  61. <a href="{{$.Repository.OriginalURL}}" class="ui poping up" data-content="{{$.i18n.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname | Safe }}"><span class="text black "><i class="fa {{MigrationIcon $.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span></a>
  62. </div>
  63. <div class="review-item-right">
  64. <span class="type-icon text {{if eq .Type 1}}green
  65. {{- else if eq .Type 2}}grey
  66. {{- else if eq .Type 3}}red
  67. {{- else if eq .Type 4}}yellow
  68. {{else}}grey{{end}}">
  69. {{svg (printf "octicon-%s" .Type.Icon)}}
  70. </span>
  71. </div>
  72. </div>
  73. {{end}}
  74. </div>
  75. </div>
  76. </div>
  77. {{end}}
  78. <div class="timeline-item comment merge box">
  79. <a class="timeline-avatar text {{if .Issue.PullRequest.HasMerged}}purple
  80. {{- else if .Issue.IsClosed}}grey
  81. {{- else if .IsPullWorkInProgress}}grey
  82. {{- else if .IsFilesConflicted}}grey
  83. {{- else if .IsPullRequestBroken}}red
  84. {{- else if .IsBlockedByApprovals}}red
  85. {{- else if .IsBlockedByRejection}}red
  86. {{- else if .IsBlockedByOfficialReviewRequests}}red
  87. {{- else if .IsBlockedByOutdatedBranch}}red
  88. {{- else if .IsBlockedByChangedProtectedFiles}}red
  89. {{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red
  90. {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow
  91. {{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red
  92. {{- else if .Issue.PullRequest.IsChecking}}yellow
  93. {{- else if .Issue.PullRequest.CanAutoMerge}}green
  94. {{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
  95. <div class="content">
  96. {{template "repo/pulls/status" .}}
  97. {{$canAutoMerge := false}}
  98. <div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
  99. {{if .Issue.PullRequest.HasMerged}}
  100. <div class="item text">
  101. {{if .Issue.PullRequest.MergedCommitID}}
  102. {{$link := printf "%s/commit/%s" $.Repository.HTMLURL .Issue.PullRequest.MergedCommitID}}
  103. {{$.i18n.Tr "repo.pulls.merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}}
  104. {{else}}
  105. {{$.i18n.Tr "repo.pulls.has_merged"}}
  106. {{end}}
  107. </div>
  108. {{if .IsPullBranchDeletable}}
  109. <div class="ui divider"></div>
  110. <div>
  111. <a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
  112. </div>
  113. {{end}}
  114. {{else if .Issue.IsClosed}}
  115. <div class="item text">
  116. {{if .IsPullRequestBroken}}
  117. {{$.i18n.Tr "repo.pulls.cant_reopen_deleted_branch"}}
  118. {{else}}
  119. {{$.i18n.Tr "repo.pulls.reopen_to_merge"}}
  120. {{end}}
  121. </div>
  122. {{if and .IsPullBranchDeletable ( not .IsPullRequestBroken )}}
  123. <div class="ui divider"></div>
  124. <div>
  125. <a class="delete-button ui red button" href="" data-url="{{.DeleteBranchLink}}">{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</a>
  126. </div>
  127. {{end}}
  128. {{else if .IsPullFilesConflicted}}
  129. <div class="item text">
  130. {{svg "octicon-x"}}
  131. {{$.i18n.Tr "repo.pulls.files_conflicted"}}
  132. {{range .ConflictedFiles}}
  133. <div>{{.}}</div>
  134. {{end}}
  135. </div>
  136. {{else if .IsPullRequestBroken}}
  137. <div class="item">
  138. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  139. {{$.i18n.Tr "repo.pulls.data_broken"}}
  140. </div>
  141. {{else if .IsPullWorkInProgress}}
  142. <div class="item">
  143. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  144. {{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" (.WorkInProgressPrefix|Escape) | Str2html}}
  145. </div>
  146. {{else if .Issue.PullRequest.IsChecking}}
  147. <div class="item">
  148. <i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
  149. {{$.i18n.Tr "repo.pulls.is_checking"}}
  150. </div>
  151. {{else if .Issue.PullRequest.CanAutoMerge}}
  152. {{if .IsBlockedByApprovals}}
  153. <div class="item">
  154. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  155. {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
  156. </div>
  157. {{else if .IsBlockedByRejection}}
  158. <div class="item">
  159. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  160. {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
  161. </div>
  162. {{else if .IsBlockedByOfficialReviewRequests}}
  163. <div class="item">
  164. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  165. {{$.i18n.Tr "repo.pulls.blocked_by_official_review_requests"}}
  166. </div>
  167. {{else if .IsBlockedByOutdatedBranch}}
  168. <div class="item">
  169. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  170. {{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
  171. </div>
  172. {{else if .IsBlockedByChangedProtectedFiles}}
  173. <div class="item">
  174. <i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
  175. {{$.i18n.Tr (TrN $.i18n.Lang $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n") | Safe }}
  176. <div class="ui ordered list">
  177. {{range .ChangedProtectedFiles}}
  178. <div data-value="-" class="item">{{.}}</div>
  179. {{end}}
  180. </div>
  181. </div>
  182. {{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
  183. <div class="item">
  184. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  185. {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
  186. </div>
  187. {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
  188. <div class="item">
  189. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  190. {{$.i18n.Tr "repo.pulls.required_status_check_missing"}}
  191. </div>
  192. {{else if and .AllowMerge .RequireSigned (not .WillSign)}}
  193. <div class="item">
  194. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  195. {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
  196. </div>
  197. <div class="item">
  198. <i class="icon unlock"></i>
  199. {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
  200. </div>
  201. {{end}}
  202. {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOfficialReviewRequests .IsBlockedByOutdatedBranch .IsBlockedByChangedProtectedFiles (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}}
  203. {{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
  204. {{if $notAllOverridableChecksOk}}
  205. <div class="item">
  206. <i class="icon icon-octicon">{{svg "octicon-dot-fill"}}</i>
  207. {{$.i18n.Tr "repo.pulls.required_status_check_administrator"}}
  208. </div>
  209. {{else}}
  210. <div class="item">
  211. <i class="icon icon-octicon">{{svg "octicon-check"}}</i>
  212. {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
  213. </div>
  214. {{end}}
  215. {{if .WillSign}}
  216. <div class="item">
  217. <i class="icon lock green"></i>
  218. {{$.i18n.Tr "repo.signing.will_sign" .SigningKey}}
  219. </div>
  220. {{else if .IsSigned}}
  221. <div class="item">
  222. <i class="icon unlock"></i>
  223. {{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
  224. </div>
  225. {{end}}
  226. {{end}}
  227. {{$canAutoMerge = true}}
  228. {{if (gt .Issue.PullRequest.CommitsBehind 0)}}
  229. <div class="ui divider"></div>
  230. <div class="item item-section">
  231. <div class="item-section-left">
  232. <i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
  233. {{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
  234. </div>
  235. <div class="item-section-right">
  236. {{if .UpdateAllowed}}
  237. <form action="{{.Link}}/update" method="post" class="ui update-branch-form">
  238. {{.CsrfTokenHtml}}
  239. <button class="ui compact button" data-do="update">
  240. <span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
  241. </button>
  242. </form>
  243. {{end}}
  244. </div>
  245. </div>
  246. {{end}}
  247. {{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}}
  248. {{if .AllowMerge}}
  249. {{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
  250. {{$approvers := .Issue.PullRequest.GetApprovers}}
  251. {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
  252. <div class="ui divider"></div>
  253. {{if $prUnit.PullRequestsConfig.AllowMerge}}
  254. <div class="ui form merge-fields" style="display: none">
  255. <form action="{{.Link}}/merge" method="post">
  256. {{.CsrfTokenHtml}}
  257. <div class="field">
  258. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
  259. </div>
  260. <div class="field">
  261. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  262. </div>
  263. <button class="ui green button" type="submit" name="do" value="merge">
  264. {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
  265. </button>
  266. <button class="ui button merge-cancel">
  267. {{$.i18n.Tr "cancel"}}
  268. </button>
  269. </form>
  270. </div>
  271. {{end}}
  272. {{if $prUnit.PullRequestsConfig.AllowRebase}}
  273. <div class="ui form rebase-fields" style="display: none">
  274. <form action="{{.Link}}/merge" method="post">
  275. {{.CsrfTokenHtml}}
  276. <button class="ui green button" type="submit" name="do" value="rebase">
  277. {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
  278. </button>
  279. <button class="ui button merge-cancel">
  280. {{$.i18n.Tr "cancel"}}
  281. </button>
  282. </form>
  283. </div>
  284. {{end}}
  285. {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
  286. <div class="ui form rebase-merge-fields" style="display: none">
  287. <form action="{{.Link}}/merge" method="post">
  288. {{.CsrfTokenHtml}}
  289. <div class="field">
  290. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
  291. </div>
  292. <div class="field">
  293. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  294. </div>
  295. <button class="ui green button" type="submit" name="do" value="rebase-merge">
  296. {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
  297. </button>
  298. <button class="ui button merge-cancel">
  299. {{$.i18n.Tr "cancel"}}
  300. </button>
  301. </form>
  302. </div>
  303. {{end}}
  304. {{if $prUnit.PullRequestsConfig.AllowSquash}}
  305. <div class="ui form squash-fields" style="display: none">
  306. <form action="{{.Link}}/merge" method="post">
  307. {{.CsrfTokenHtml}}
  308. <div class="field">
  309. <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultSquashMessage}}">
  310. </div>
  311. <div class="field">
  312. <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">{{.GetCommitMessages}}Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
  313. </div>
  314. <button class="ui green button" type="submit" name="do" value="squash">
  315. {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
  316. </button>
  317. <button class="ui button merge-cancel">
  318. {{$.i18n.Tr "cancel"}}
  319. </button>
  320. </form>
  321. </div>
  322. {{end}}
  323. <div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button">
  324. <button class="ui button" data-do="{{.MergeStyle}}">
  325. {{svg "octicon-git-merge"}}
  326. <span class="button-text">
  327. {{if eq .MergeStyle "merge"}}
  328. {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
  329. {{end}}
  330. {{if eq .MergeStyle "rebase"}}
  331. {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
  332. {{end}}
  333. {{if eq .MergeStyle "rebase-merge"}}
  334. {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
  335. {{end}}
  336. {{if eq .MergeStyle "squash"}}
  337. {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
  338. {{end}}
  339. </span>
  340. </button>
  341. {{if gt $prUnit.PullRequestsConfig.AllowedMergeStyleCount 1}}
  342. <div class="ui dropdown icon button">
  343. {{svg "octicon-triangle-down" 14 "dropdown icon"}}
  344. <div class="menu">
  345. {{if $prUnit.PullRequestsConfig.AllowMerge}}
  346. <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
  347. {{end}}
  348. {{if $prUnit.PullRequestsConfig.AllowRebase}}
  349. <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
  350. {{end}}
  351. {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
  352. <div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
  353. {{end}}
  354. {{if $prUnit.PullRequestsConfig.AllowSquash}}
  355. <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
  356. {{end}}
  357. </div>
  358. </div>
  359. {{end}}
  360. </div>
  361. {{else}}
  362. <div class="ui divider"></div>
  363. <div class="item text red">
  364. {{svg "octicon-x"}}
  365. {{$.i18n.Tr "repo.pulls.no_merge_desc"}}
  366. </div>
  367. <div class="item text grey">
  368. {{svg "octicon-info"}}
  369. {{$.i18n.Tr "repo.pulls.no_merge_helper"}}
  370. </div>
  371. {{end}}
  372. {{else}}
  373. <div class="ui divider"></div>
  374. <div class="item text grey">
  375. {{svg "octicon-info"}}
  376. {{$.i18n.Tr "repo.pulls.no_merge_access"}}
  377. </div>
  378. {{end}}
  379. {{end}}
  380. {{else}}
  381. {{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
  382. {{if .IsBlockedByApprovals}}
  383. <div class="item text red">
  384. {{svg "octicon-x"}}
  385. {{$.i18n.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .Issue.PullRequest.ProtectedBranch.RequiredApprovals}}
  386. </div>
  387. {{else if .IsBlockedByRejection}}
  388. <div class="item text red">
  389. {{svg "octicon-x"}}
  390. {{$.i18n.Tr "repo.pulls.blocked_by_rejection"}}
  391. </div>
  392. {{else if .IsBlockedByOfficialReviewRequests}}
  393. <div class="item text red">
  394. {{svg "octicon-x"}}
  395. {{$.i18n.Tr "repo.pulls.blocked_by_official_review_requests"}}
  396. </div>
  397. {{else if .IsBlockedByOutdatedBranch}}
  398. <div class="item text red">
  399. <i class="icon icon-octicon">{{svg "octicon-x"}}</i>
  400. {{$.i18n.Tr "repo.pulls.blocked_by_outdated_branch"}}
  401. </div>
  402. {{else if .IsBlockedByChangedProtectedFiles}}
  403. <div class="item text red">
  404. <i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
  405. {{$.i18n.Tr (TrN $.i18n.Lang $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n") | Safe }}
  406. <div class="ui ordered list">
  407. {{range .ChangedProtectedFiles}}
  408. <div data-value="-" class="item">{{.}}</div>
  409. {{end}}
  410. </div>
  411. </div>
  412. {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
  413. <div class="item text red">
  414. {{svg "octicon-x"}}
  415. {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
  416. </div>
  417. {{else if and .RequireSigned (not .WillSign)}}
  418. <div class="item text red">
  419. {{svg "octicon-x"}}
  420. {{$.i18n.Tr "repo.pulls.require_signed_wont_sign"}}
  421. </div>
  422. {{else}}
  423. <div class="item text red">
  424. {{svg "octicon-x"}}
  425. {{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}}
  426. </div>
  427. <div class="item text grey">
  428. {{svg "octicon-info"}}
  429. {{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}}
  430. </div>
  431. {{end}}
  432. {{end}}
  433. {{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
  434. <div class="item text grey">
  435. <i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
  436. {{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
  437. {{if .UpdateAllowed}}
  438. <form action="{{.Link}}/update" method="post" class="ui floating right">
  439. {{.CsrfTokenHtml}}
  440. <button class="ui compact button" data-do="update">
  441. <span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
  442. </button>
  443. </form>
  444. {{end}}
  445. </div>
  446. {{end}}
  447. </div>
  448. </div>
  449. </div>