[v12.0/forgejo] fix: show mergebox when only manual merge is allowed (#8683)

**Backport:** https://codeberg.org/forgejo/forgejo/pulls/8681

- If a repository only has the 'manual merge' strategy allowed, the mergebox should still be shown.
- The condition that checks if all merge strategies are disabled didn't check for the manual merge strategy.
- Add a integration test that demonstrates this fix is effective.

Reported-by: apteryx
Co-authored-by: Gusted <postmaster@gusted.xyz>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8683
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
forgejo-backport-action 2025-07-26 16:07:56 +02:00 committed by Earl Warren
commit 1efd54b94f
2 changed files with 22 additions and 1 deletions

View file

@ -199,7 +199,7 @@
{{if .AllowMerge}} {{/* user is allowed to merge */}} {{if .AllowMerge}} {{/* user is allowed to merge */}}
{{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}} {{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}}
{{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash $prUnit.PullRequestsConfig.AllowFastForwardOnly}} {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash $prUnit.PullRequestsConfig.AllowFastForwardOnly $prUnit.PullRequestsConfig.AllowManualMerge}}
{{$hasPendingPullRequestMergeTip := ""}} {{$hasPendingPullRequestMergeTip := ""}}
{{if .HasPendingPullRequestMerge}} {{if .HasPendingPullRequestMerge}}
{{$createdPRMergeStr := DateUtils.TimeSince .PendingPullRequestMerge.CreatedUnix}} {{$createdPRMergeStr := DateUtils.TimeSince .PendingPullRequestMerge.CreatedUnix}}

View file

@ -136,3 +136,24 @@ func TestPullCombinedReviewRequest(t *testing.T) {
helper(t, "detach", "9", "removed review request for user11") helper(t, "detach", "9", "removed review request for user11")
helper(t, "detach", "2", "removed review requests for user11, user2") helper(t, "detach", "2", "removed review requests for user11, user2")
} }
func TestShowMergeForManualMerge(t *testing.T) {
defer tests.PrepareTestEnv(t)()
// Only allow manual merge strategy for this repository.
pullRepoUnit := unittest.AssertExistsAndLoadBean(t, &repo_model.RepoUnit{ID: 5, RepoID: 1, Type: unit.TypePullRequests})
pullRepoUnit.Config = &repo_model.PullRequestsConfig{
AllowManualMerge: true,
DefaultMergeStyle: repo_model.MergeStyleManuallyMerged,
}
repo_model.UpdateRepoUnit(t.Context(), pullRepoUnit)
session := loginUser(t, "user2")
req := NewRequest(t, "GET", "/user2/repo1/pulls/5")
resp := session.MakeRequest(t, req, http.StatusOK)
// Assert that the mergebox is shown.
htmlDoc := NewHTMLParser(t, resp.Body)
htmlDoc.AssertElement(t, "#pull-request-merge-form", true)
}