diff --git a/.gitea/actions/review/action.yml b/.gitea/actions/review/action.yml index d005697..0fdccdc 100644 --- a/.gitea/actions/review/action.yml +++ b/.gitea/actions/review/action.yml @@ -67,7 +67,7 @@ inputs: required: false default: 'false' update-existing: - description: 'Delete previous review from same bot before posting (default true)' + description: 'Delete previous review from same bot before posting. Accepts: true/1/yes or false/0/no (default true)' required: false default: 'true' diff --git a/cmd/review-bot/main.go b/cmd/review-bot/main.go index 39865b4..c9e414f 100644 --- a/cmd/review-bot/main.go +++ b/cmd/review-bot/main.go @@ -359,7 +359,7 @@ func envOrDefaultInt(key string, defaultVal int) int { } func envOrDefaultBool(key string, defaultVal bool) bool { - v := os.Getenv(key) + v := strings.TrimSpace(strings.ToLower(os.Getenv(key))) if v == "" { return defaultVal } diff --git a/gitea/client.go b/gitea/client.go index f21b1d5..a77e111 100644 --- a/gitea/client.go +++ b/gitea/client.go @@ -298,7 +298,7 @@ func (c *Client) GetAuthenticatedUser(ctx context.Context) (string, error) { // ListReviews returns all reviews on a pull request. func (c *Client) ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error) { - reqURL := fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/reviews", + reqURL := fmt.Sprintf("%s/api/v1/repos/%s/%s/pulls/%d/reviews?limit=50", c.baseURL, url.PathEscape(owner), url.PathEscape(repo), diff --git a/gitea/client_test.go b/gitea/client_test.go index fc93473..7ca9b21 100644 --- a/gitea/client_test.go +++ b/gitea/client_test.go @@ -361,6 +361,9 @@ func TestListReviews(t *testing.T) { if r.URL.Path != "/api/v1/repos/owner/repo/pulls/5/reviews" { t.Errorf("unexpected path: %s", r.URL.Path) } + if r.URL.Query().Get("limit") != "50" { + t.Errorf("expected limit=50, got %s", r.URL.Query().Get("limit")) + } w.Header().Set("Content-Type", "application/json") w.Write([]byte(`[{"id":10,"user":{"login":"bot-a"},"state":"APPROVED","stale":false},{"id":11,"user":{"login":"bot-b"},"state":"REQUEST_CHANGES","stale":true}]`)) }))