mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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>
This commit is contained in:
@@ -83,7 +83,17 @@
|
||||
{{end}}
|
||||
|
||||
{{if .IsNothingToCompare}}
|
||||
<div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div>
|
||||
{{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived) }}
|
||||
<div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare_and_allow_empty_pr"}}</div>
|
||||
<div class="ui info message show-form-container">
|
||||
<button class="ui button green show-form">{{.i18n.Tr "repo.pulls.new"}}</button>
|
||||
</div>
|
||||
<div class="pullrequest-form" style="display: none">
|
||||
{{template "repo/issue/new_form" .}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="ui segment">{{.i18n.Tr "repo.pulls.nothing_to_compare"}}</div>
|
||||
{{end}}
|
||||
{{else if and .PageIsComparePull (gt .CommitCount 0)}}
|
||||
{{if .HasPullRequest}}
|
||||
<div class="ui segment">
|
||||
|
@@ -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}}
|
||||
|
@@ -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>
|
||||
|
@@ -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}}
|
||||
|
@@ -330,6 +330,18 @@
|
||||
<label>{{.i18n.Tr "repo.settings.pulls.allow_squash_commits"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input name="pulls_allow_manual_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowManualMerge)}}checked{{end}}>
|
||||
<label>{{.i18n.Tr "repo.settings.pulls.allow_manual_merge"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input name="enable_autodetect_manual_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AutodetectManualMerge)}}checked{{end}}>
|
||||
<label>{{.i18n.Tr "repo.settings.pulls.enable_autodetect_manual_merge"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
@@ -13586,6 +13586,11 @@
|
||||
"description": "EditRepoOption options when editing a repository's properties",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allow_manual_merge": {
|
||||
"description": "either `true` to allow mark pr as merged manually, or `false` to prevent it. `has_pull_requests` must be `true`.",
|
||||
"type": "boolean",
|
||||
"x-go-name": "AllowManualMerge"
|
||||
},
|
||||
"allow_merge_commits": {
|
||||
"description": "either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_pull_requests` must be `true`.",
|
||||
"type": "boolean",
|
||||
@@ -13611,6 +13616,11 @@
|
||||
"type": "boolean",
|
||||
"x-go-name": "Archived"
|
||||
},
|
||||
"autodetect_manual_merge": {
|
||||
"description": "either `true` to enable AutodetectManualMerge, or `false` to prevent it. `has_pull_requests` must be `true`, Note: In some special cases, misjudgments can occur.",
|
||||
"type": "boolean",
|
||||
"x-go-name": "AutodetectManualMerge"
|
||||
},
|
||||
"default_branch": {
|
||||
"description": "sets the default branch for this repository.",
|
||||
"type": "string",
|
||||
@@ -14596,9 +14606,13 @@
|
||||
"merge",
|
||||
"rebase",
|
||||
"rebase-merge",
|
||||
"squash"
|
||||
"squash",
|
||||
"manually-merged"
|
||||
]
|
||||
},
|
||||
"MergeCommitID": {
|
||||
"type": "string"
|
||||
},
|
||||
"MergeMessageField": {
|
||||
"type": "string"
|
||||
},
|
||||
|
Reference in New Issue
Block a user