Allow pull requests Manually Merged option to be used by non-admins (#27780)
Currently this feature is only available to admins, but there is no clear reason why. If a user can actually merge pull requests, then this seems fine as well. This is useful in situations where direct pushes to the repository are commonly done by developers. --------- Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
b36e2ca419
commit
1756e30e10
2 changed files with 8 additions and 6 deletions
|
@ -1773,7 +1773,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
pull := issue.PullRequest
|
pull := issue.PullRequest
|
||||||
pull.Issue = issue
|
pull.Issue = issue
|
||||||
canDelete := false
|
canDelete := false
|
||||||
ctx.Data["AllowMerge"] = false
|
allowMerge := false
|
||||||
|
|
||||||
if ctx.IsSigned {
|
if ctx.IsSigned {
|
||||||
if err := pull.LoadHeadRepo(ctx); err != nil {
|
if err := pull.LoadHeadRepo(ctx); err != nil {
|
||||||
|
@ -1806,7 +1806,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.ServerError("GetUserRepoPermission", err)
|
ctx.ServerError("GetUserRepoPermission", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Data["AllowMerge"], err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
|
allowMerge, err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("IsUserAllowedToMerge", err)
|
ctx.ServerError("IsUserAllowedToMerge", err)
|
||||||
return
|
return
|
||||||
|
@ -1818,6 +1818,8 @@ func ViewIssue(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["AllowMerge"] = allowMerge
|
||||||
|
|
||||||
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
|
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetUnit", err)
|
ctx.ServerError("GetUnit", err)
|
||||||
|
@ -1927,7 +1929,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
if pull.CanAutoMerge() || pull.IsWorkInProgress(ctx) || pull.IsChecking() {
|
if pull.CanAutoMerge() || pull.IsWorkInProgress(ctx) || pull.IsChecking() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (ctx.Doer.IsAdmin || ctx.Repo.IsAdmin()) && prConfig.AllowManualMerge {
|
if allowMerge && prConfig.AllowManualMerge {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,7 +263,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'manually-merged',
|
'name': 'manually-merged',
|
||||||
'allowed': {{and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}},
|
'allowed': {{$prUnit.PullRequestsConfig.AllowManualMerge}},
|
||||||
'textDoMerge': {{ctx.Locale.Tr "repo.pulls.merge_manually"}},
|
'textDoMerge': {{ctx.Locale.Tr "repo.pulls.merge_manually"}},
|
||||||
'hideMergeMessageTexts': true,
|
'hideMergeMessageTexts': true,
|
||||||
'hideAutoMerge': true,
|
'hideAutoMerge': true,
|
||||||
|
@ -349,13 +349,13 @@
|
||||||
{{end}}{{/* end if: pull request status */}}
|
{{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
|
Manually Merged is not a well-known feature, it is used to mark a non-mergeable PR (already merged, conflicted) as merged
|
||||||
To test it:
|
To test it:
|
||||||
* Enable "Manually Merged" feature in the Repository Settings
|
* Enable "Manually Merged" feature in the Repository Settings
|
||||||
* Create a pull request, either:
|
* Create a pull request, either:
|
||||||
* - Merge the pull request branch locally and push the merged commit to Gitea
|
* - 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
|
* - Make some conflicts between the base branch and the pull request branch
|
||||||
* Then the Manually Merged form will be shown to repo admin users
|
* Then the Manually Merged form will be shown in the merge form
|
||||||
*/}}
|
*/}}
|
||||||
{{if and $.StillCanManualMerge (not $showGeneralMergeForm)}}
|
{{if and $.StillCanManualMerge (not $showGeneralMergeForm)}}
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
Loading…
Reference in a new issue