mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-31 19:55:02 +00:00
Backport #40118 by @lazerg 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 Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com>
This commit is contained in:
1 parent
5ba69f9af4
commit
c9e1805cc9
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
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"gitea.dev/models/unittest"
|
||||
user_model "gitea.dev/models/user"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -403,6 +404,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