Skip to content

Commit 1756e30

Browse files
brechtvldelvh
andauthored
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 <[email protected]>
1 parent b36e2ca commit 1756e30

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

routers/web/repo/issue.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ func ViewIssue(ctx *context.Context) {
17731773
pull := issue.PullRequest
17741774
pull.Issue = issue
17751775
canDelete := false
1776-
ctx.Data["AllowMerge"] = false
1776+
allowMerge := false
17771777

17781778
if ctx.IsSigned {
17791779
if err := pull.LoadHeadRepo(ctx); err != nil {
@@ -1806,7 +1806,7 @@ func ViewIssue(ctx *context.Context) {
18061806
ctx.ServerError("GetUserRepoPermission", err)
18071807
return
18081808
}
1809-
ctx.Data["AllowMerge"], err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
1809+
allowMerge, err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
18101810
if err != nil {
18111811
ctx.ServerError("IsUserAllowedToMerge", err)
18121812
return
@@ -1818,6 +1818,8 @@ func ViewIssue(ctx *context.Context) {
18181818
}
18191819
}
18201820

1821+
ctx.Data["AllowMerge"] = allowMerge
1822+
18211823
prUnit, err := repo.GetUnit(ctx, unit.TypePullRequests)
18221824
if err != nil {
18231825
ctx.ServerError("GetUnit", err)
@@ -1927,7 +1929,7 @@ func ViewIssue(ctx *context.Context) {
19271929
if pull.CanAutoMerge() || pull.IsWorkInProgress(ctx) || pull.IsChecking() {
19281930
return false
19291931
}
1930-
if (ctx.Doer.IsAdmin || ctx.Repo.IsAdmin()) && prConfig.AllowManualMerge {
1932+
if allowMerge && prConfig.AllowManualMerge {
19311933
return true
19321934
}
19331935

templates/repo/issue/view_content/pull.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
},
264264
{
265265
'name': 'manually-merged',
266-
'allowed': {{and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}},
266+
'allowed': {{$prUnit.PullRequestsConfig.AllowManualMerge}},
267267
'textDoMerge': {{ctx.Locale.Tr "repo.pulls.merge_manually"}},
268268
'hideMergeMessageTexts': true,
269269
'hideAutoMerge': true,
@@ -349,13 +349,13 @@
349349
{{end}}{{/* end if: pull request status */}}
350350

351351
{{/*
352-
Manually Merged is not a well-known feature, it helps repo admins to mark a non-mergeable PR (already merged, conflicted) as merged
352+
Manually Merged is not a well-known feature, it is used to mark a non-mergeable PR (already merged, conflicted) as merged
353353
To test it:
354354
* Enable "Manually Merged" feature in the Repository Settings
355355
* Create a pull request, either:
356356
* - Merge the pull request branch locally and push the merged commit to Gitea
357357
* - Make some conflicts between the base branch and the pull request branch
358-
* Then the Manually Merged form will be shown to repo admin users
358+
* Then the Manually Merged form will be shown in the merge form
359359
*/}}
360360
{{if and $.StillCanManualMerge (not $showGeneralMergeForm)}}
361361
<div class="divider"></div>

0 commit comments

Comments
 (0)