mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-02 13:44:16 +09:00
fix(pull): respect max approvers in default merge message (#40118)
The approver limit was checked before writing each `Reviewed-by:` line but compared with `>`, so the default merge message got one more trailer than `DEFAULT_MERGE_MESSAGE_MAX_APPROVERS` allows (2 with a limit of 1, 11 with the default 10). It now stops once the limit is reached. Fixes https://github.com/go-gitea/gitea/issues/40116 Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
b89fcf7496
commit
8465bed994
2 files changed
+6
-1
No files matched your search
@@ -378,7 +378,7 @@ func (pr *PullRequest) getReviewedByLines(ctx context.Context, writer io.Writer)
|
||||
reviewersWritten := 0
|
||||
|
||||
for _, review := range reviews {
|
||||
if maxReviewers > 0 && reviewersWritten > maxReviewers {
|
||||
if maxReviewers > 0 && reviewersWritten >= maxReviewers {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
user_model "gitea.dev/models/user"
|
||||
"gitea.dev/modules/optional"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -404,6 +405,10 @@ func testGetApprovers(t *testing.T) {
|
||||
approvers := pr.GetApprovers(t.Context())
|
||||
expected := "Reviewed-by: User Five <user5@example.com>\nReviewed-by: Org Six <org6@example.com>\n"
|
||||
assert.Equal(t, expected, approvers)
|
||||
|
||||
defer test.MockVariableValue(&setting.Repository.PullRequest.DefaultMergeMessageMaxApprovers, 1)()
|
||||
approvers = pr.GetApprovers(t.Context())
|
||||
assert.Equal(t, "Reviewed-by: User Five <user5@example.com>\n", approvers)
|
||||
}
|
||||
|
||||
func testGetPullRequestByMergedCommit(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user