aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/issue
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-09-18 13:39:45 +0800
committerLauris BH <lauris@nix.lv>2019-09-18 08:39:45 +0300
commit04ca7f004710de2b408f558f6f148894aa61ba57 (patch)
tree57fea3b9853127897676faaf9e70abace2565878 /templates/repo/issue
parent29454733b4eeea33e6c94c50b32855066c203988 (diff)
downloadgitea-04ca7f004710de2b408f558f6f148894aa61ba57.tar.gz
gitea-04ca7f004710de2b408f558f6f148894aa61ba57.zip
Refuse merge until all required status checks success (#7481)
* refuse merge until ci successfully * deny merge request when required status checkes not succeed on merge Post and API * add database migration for added columns on protected_branch * fix migration * fix protected branch check bug * fix protected branch settings * remove duplicated code on check pull request's required commit statuses pass * remove unused codes * fix migration * add newline for template file * fix go mod * rename function name and some other fixes * fix template * fix bug pull view * remove go1.12 wrong dependencies * add administrator bypass when protected branch status check enabled * fix bug * improve the codes
Diffstat (limited to 'templates/repo/issue')
-rw-r--r--templates/repo/issue/view_content/pull.tmpl249
1 files changed, 135 insertions, 114 deletions
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index f0e39d5e37..f5ce8e0886 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -41,6 +41,7 @@
{{else if .IsFilesConflicted}}grey
{{else if .IsPullRequestBroken}}red
{{else if .IsBlockedByApprovals}}red
+ {{else if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}red
{{else if .Issue.PullRequest.IsChecking}}yellow
{{else if .Issue.PullRequest.CanAutoMerge}}green
{{else}}red{{end}}"><span class="mega-octicon octicon-git-merge"></span></a>
@@ -104,130 +105,150 @@
<span class="octicon octicon-sync"></span>
{{$.i18n.Tr "repo.pulls.is_checking"}}
</div>
+ {{else if and (not .Issue.PullRequest.CanAutoMerge) .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
+ <div class="item text red">
+ <span class="octicon octicon-x"></span>
+ {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
+ </div>
{{else if .Issue.PullRequest.CanAutoMerge}}
- <div class="item text green">
- <span class="octicon octicon-check"></span>
- {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
+ {{if and .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
+ <div class="item text red">
+ <span class="octicon octicon-x"></span>
+ {{$.i18n.Tr "repo.pulls.required_status_check_failed"}}
</div>
- {{if .AllowMerge}}
- {{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
- {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
- <div class="ui divider"></div>
- {{if $prUnit.PullRequestsConfig.AllowMerge}}
- <div class="ui form merge-fields" style="display: none">
- <form action="{{.Link}}/merge" method="post">
- {{.CsrfTokenHtml}}
- <div class="field">
- <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
- </div>
- <div class="field">
- <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
- </div>
- <button class="ui green button" type="submit" name="do" value="merge">
- {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
- </button>
- <button class="ui button merge-cancel">
- {{$.i18n.Tr "cancel"}}
- </button>
- </form>
- </div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebase}}
- <div class="ui form rebase-fields" style="display: none">
- <form action="{{.Link}}/merge" method="post">
- {{.CsrfTokenHtml}}
- <button class="ui green button" type="submit" name="do" value="rebase">
- {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
- </button>
- <button class="ui button merge-cancel">
- {{$.i18n.Tr "cancel"}}
- </button>
- </form>
- </div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
- <div class="ui form rebase-merge-fields" style="display: none">
- <form action="{{.Link}}/merge" method="post">
- {{.CsrfTokenHtml}}
- <div class="field">
- <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
- </div>
- <div class="field">
- <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
- </div>
- <button class="ui green button" type="submit" name="do" value="rebase-merge">
- {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
- </button>
- <button class="ui button merge-cancel">
- {{$.i18n.Tr "cancel"}}
- </button>
- </form>
+ {{end}}
+ {{if or $.IsRepoAdmin (not .EnableStatusCheck) .IsRequiredStatusCheckSuccess}}
+ {{if and $.IsRepoAdmin .EnableStatusCheck (not .IsRequiredStatusCheckSuccess)}}
+ <div class="item text yellow">
+ <span class="octicon octicon-primitive-dot"></span>
+ {{$.i18n.Tr "repo.pulls.required_status_check_administrator"}}
</div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowSquash}}
- <div class="ui form squash-fields" style="display: none">
- <form action="{{.Link}}/merge" method="post">
- {{.CsrfTokenHtml}}
- <div class="field">
- <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultSquashMessage}}">
- </div>
- <div class="field">
- <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
- </div>
- <button class="ui green button" type="submit" name="do" value="squash">
- {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
- </button>
- <button class="ui button merge-cancel">
- {{$.i18n.Tr "cancel"}}
- </button>
- </form>
+ {{else}}
+ <div class="item text green">
+ <span class="octicon octicon-check"></span>
+ {{$.i18n.Tr "repo.pulls.can_auto_merge_desc"}}
</div>
- {{end}}
- <div class="ui green buttons merge-button">
- <button class="ui button" data-do="{{.MergeStyle}}">
- <span class="octicon octicon-git-merge"></span>
- <span class="button-text">
- {{if eq .MergeStyle "merge"}}
- {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
- {{end}}
- {{if eq .MergeStyle "rebase"}}
- {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
- {{end}}
- {{if eq .MergeStyle "rebase-merge"}}
- {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
- {{end}}
- {{if eq .MergeStyle "squash"}}
- {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
- {{end}}
- </span>
- </button>
- <div class="ui dropdown icon button">
- <i class="dropdown icon"></i>
- <div class="menu">
- {{if $prUnit.PullRequestsConfig.AllowMerge}}
- <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
+ {{end}}
+ {{if .AllowMerge}}
+ {{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
+ {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}
+ <div class="ui divider"></div>
+ {{if $prUnit.PullRequestsConfig.AllowMerge}}
+ <div class="ui form merge-fields" style="display: none">
+ <form action="{{.Link}}/merge" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="field">
+ <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
+ </div>
+ <div class="field">
+ <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
+ </div>
+ <button class="ui green button" type="submit" name="do" value="merge">
+ {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
+ </button>
+ <button class="ui button merge-cancel">
+ {{$.i18n.Tr "cancel"}}
+ </button>
+ </form>
+ </div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebase}}
+ <div class="ui form rebase-fields" style="display: none">
+ <form action="{{.Link}}/merge" method="post">
+ {{.CsrfTokenHtml}}
+ <button class="ui green button" type="submit" name="do" value="rebase">
+ {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
+ </button>
+ <button class="ui button merge-cancel">
+ {{$.i18n.Tr "cancel"}}
+ </button>
+ </form>
+ </div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
+ <div class="ui form rebase-merge-fields" style="display: none">
+ <form action="{{.Link}}/merge" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="field">
+ <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultMergeMessage}}">
+ </div>
+ <div class="field">
+ <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
+ </div>
+ <button class="ui green button" type="submit" name="do" value="rebase-merge">
+ {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
+ </button>
+ <button class="ui button merge-cancel">
+ {{$.i18n.Tr "cancel"}}
+ </button>
+ </form>
+ </div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowSquash}}
+ <div class="ui form squash-fields" style="display: none">
+ <form action="{{.Link}}/merge" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="field">
+ <input type="text" name="merge_title_field" value="{{.Issue.PullRequest.GetDefaultSquashMessage}}">
+ </div>
+ <div class="field">
+ <textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}"></textarea>
+ </div>
+ <button class="ui green button" type="submit" name="do" value="squash">
+ {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
+ </button>
+ <button class="ui button merge-cancel">
+ {{$.i18n.Tr "cancel"}}
+ </button>
+ </form>
+ </div>
+ {{end}}
+ <div class="ui green buttons merge-button">
+ <button class="ui button" data-do="{{.MergeStyle}}">
+ <span class="octicon octicon-git-merge"></span>
+ <span class="button-text">
+ {{if eq .MergeStyle "merge"}}
+ {{$.i18n.Tr "repo.pulls.merge_pull_request"}}
{{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebase}}
- <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
+ {{if eq .MergeStyle "rebase"}}
+ {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
{{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
- <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>
+ {{if eq .MergeStyle "rebase-merge"}}
+ {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
{{end}}
- {{if $prUnit.PullRequestsConfig.AllowSquash}}
- <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
+ {{if eq .MergeStyle "squash"}}
+ {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
{{end}}
+ </span>
+ </button>
+ <div class="ui dropdown icon button">
+ <i class="dropdown icon"></i>
+ <div class="menu">
+ {{if $prUnit.PullRequestsConfig.AllowMerge}}
+ <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebase}}
+ <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
+ <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>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowSquash}}
+ <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
+ {{end}}
+ </div>
</div>
</div>
- </div>
- {{else}}
- <div class="item text red">
- <span class="octicon octicon-x"></span>
- {{$.i18n.Tr "repo.pulls.no_merge_desc"}}
- </div>
- <div class="item text grey">
- <span class="octicon octicon-info"></span>
- {{$.i18n.Tr "repo.pulls.no_merge_helper"}}
- </div>
+ {{else}}
+ <div class="item text red">
+ <span class="octicon octicon-x"></span>
+ {{$.i18n.Tr "repo.pulls.no_merge_desc"}}
+ </div>
+ <div class="item text grey">
+ <span class="octicon octicon-info"></span>
+ {{$.i18n.Tr "repo.pulls.no_merge_helper"}}
+ </div>
+ {{end}}
{{end}}
{{end}}
{{else}}