diff options
author | a1012112796 <1012112796@qq.com> | 2021-03-04 11:41:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-03 22:41:23 -0500 |
commit | a5279b74b63248902a6572df5afa3745367e6cb9 (patch) | |
tree | 7f1fac744013b533bfb0580d48a27d0aae5ab04e /templates/repo/issue | |
parent | 523efa433b61e00e7a14bd31cac315e43842d729 (diff) | |
download | gitea-a5279b74b63248902a6572df5afa3745367e6cb9.tar.gz gitea-a5279b74b63248902a6572df5afa3745367e6cb9.zip |
Make manual merge autodetection optional and add manual merge as merge method (#12543)
* Make auto check manual merge as a chooseable mod and add manual merge way on ui
as title, Before this pr, we use same way with GH to check manually merge.
It good, but in some special cases, misjudgments can occur. and it's hard
to fix this bug. So I add option to allow repo manager block "auto check manual merge"
function, Then it will have same style like gitlab(allow empty pr). and to compensate for
not being able to detect THE PR merge automatically, I added a manual approach.
Signed-off-by: a1012112796 <1012112796@qq.com>
* make swager
* api support
* ping ci
* fix TestPullCreate_EmptyChangesWithCommits
* Apply suggestions from code review
Co-authored-by: zeripath <art27@cantab.net>
* Apply review suggestions and add test
* Apply suggestions from code review
Co-authored-by: zeripath <art27@cantab.net>
* fix build
* test error message
* make fmt
* Fix indentation issues identified by @silverwind
Co-authored-by: silverwind <me@silverwind.io>
* Fix tests and make manually merged disabled error on API the same
Signed-off-by: Andrew Thornton <art27@cantab.net>
* a small nit
* fix wrong commit id error
* fix bug
* simple test
* fix test
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'templates/repo/issue')
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 6 | ||||
-rw-r--r-- | templates/repo/issue/view_content/pull.tmpl | 58 | ||||
-rw-r--r-- | templates/repo/issue/view_title.tmpl | 2 |
3 files changed, 63 insertions, 3 deletions
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index cfacde9648..b8d78f5697 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -124,7 +124,11 @@ <span class="text grey"> <a class="author" href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$link := printf "%s/commit/%s" $.Repository.HTMLURL $.Issue.PullRequest.MergedCommitID}} - {{$.i18n.Tr "repo.issues.pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}} + {{if eq $.Issue.PullRequest.Status 3}} + {{$.i18n.Tr "repo.issues.manually_pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) $.BaseTarget $createdStr | Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) $.BaseTarget $createdStr | Str2html}} + {{end}} </span> </div> {{else if eq .Type 3 5 6}} diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 9e883c0a93..2175fad067 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -118,6 +118,7 @@ {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow {{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red {{- else if .Issue.PullRequest.IsChecking}}yellow + {{- else if .Issue.PullRequest.IsEmpty}}grey {{- else if .Issue.PullRequest.CanAutoMerge}}green {{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a> <div class="content"> @@ -128,7 +129,11 @@ <div class="item text"> {{if .Issue.PullRequest.MergedCommitID}} {{$link := printf "%s/commit/%s" $.Repository.HTMLURL .Issue.PullRequest.MergedCommitID}} - {{$.i18n.Tr "repo.pulls.merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}} + {{if eq $.Issue.PullRequest.Status 3}} + {{$.i18n.Tr "repo.pulls.manually_merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}} + {{else}} + {{$.i18n.Tr "repo.pulls.merged_as" $link (ShortSha .Issue.PullRequest.MergedCommitID) | Safe}} + {{end}} {{else}} {{$.i18n.Tr "repo.pulls.has_merged"}} {{end}} @@ -176,6 +181,11 @@ <i class="icon icon-octicon">{{svg "octicon-sync"}}</i> {{$.i18n.Tr "repo.pulls.is_checking"}} </div> + {{else if .Issue.PullRequest.IsEmpty}} + <div class="item text grey"> + <i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i> + {{$.i18n.Tr "repo.pulls.is_empty"}} + </div> {{else if .Issue.PullRequest.CanAutoMerge}} {{if .IsBlockedByApprovals}} <div class="item"> @@ -350,6 +360,22 @@ </form> </div> {{end}} + {{if and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}} + <div class="ui form manually-merged-fields" style="display: none"> + <form action="{{.Link}}/merge" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <input type="text" name="merge_commit_id" placeholder="{{$.i18n.Tr "repo.pulls.merge_commit_id"}}"> + </div> + <button class="ui red button" type="submit" name="do" value="manually-merged"> + {{$.i18n.Tr "repo.pulls.merge_manually"}} + </button> + <button class="ui button merge-cancel"> + {{$.i18n.Tr "cancel"}} + </button> + </form> + </div> + {{end}} <div class="dib"> <div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button"> <button class="ui button" data-do="{{.MergeStyle}}"> @@ -367,6 +393,9 @@ {{if eq .MergeStyle "squash"}} {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}} {{end}} + {{if eq .MergeStyle "manually-merged"}} + {{$.i18n.Tr "repo.pulls.merge_manually"}} + {{end}} </span> </button> {{if gt $prUnit.PullRequestsConfig.AllowedMergeStyleCount 1}} @@ -385,6 +414,9 @@ {{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}} + {{if and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}} + <div class="item{{if eq .MergeStyle "manually-merged"}} active selected{{end}}" data-do="manually-merged">{{$.i18n.Tr "repo.pulls.merge_manually"}}</div> + {{end}} </div> </div> {{end}} @@ -492,6 +524,30 @@ {{end}} </div> {{end}} + + {{if $.StillCanManualMerge}} + <div class="ui divider"></div> + <div class="ui form manually-merged-fields" style="display: none"> + <form action="{{.Link}}/merge" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <input type="text" name="merge_commit_id" placeholder="{{$.i18n.Tr "repo.pulls.merge_commit_id"}}"> + </div> + <button class="ui red button" type="submit" name="do" value="manually-merged"> + {{$.i18n.Tr "repo.pulls.merge_manually"}} + </button> + <button class="ui button merge-cancel"> + {{$.i18n.Tr "cancel"}} + </button> + </form> + </div> + + <div class="ui red buttons merge-button"> + <button class="ui button" data-do="manually-merged"> + {{$.i18n.Tr "repo.pulls.merge_manually"}} + </button> + </div> + {{end}} </div> </div> </div> diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index 2f2787d67c..f6cbb9206c 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -20,7 +20,7 @@ {{end}} </div> {{if .HasMerged}} - <div class="ui purple large label">{{svg "octicon-git-merge"}} {{.i18n.Tr "repo.pulls.merged"}}</div> + <div class="ui purple large label">{{svg "octicon-git-merge" 16}} {{if eq .Issue.PullRequest.Status 3}}{{.i18n.Tr "repo.pulls.manually_merged"}}{{else}}{{.i18n.Tr "repo.pulls.merged"}}{{end}}</div> {{else if .Issue.IsClosed}} <div class="ui red large label">{{if .Issue.IsPull}}{{svg "octicon-git-pull-request"}}{{else}}{{svg "octicon-issue-closed"}}{{end}} {{.i18n.Tr "repo.issues.closed_title"}}</div> {{else if .Issue.IsPull}} |