fix: address review findings (pagination, case-insensitive bool, docs)
- ListReviews: add ?limit=50 to handle PRs with many reviews - envOrDefaultBool: case-insensitive, whitespace-trimmed (TRUE/Yes/1 all work) - action.yml: document accepted boolean values in description - Test: verify limit query parameter is sent
This commit is contained in:
@@ -67,7 +67,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
update-existing:
|
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
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ func envOrDefaultInt(key string, defaultVal int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func envOrDefaultBool(key string, defaultVal bool) bool {
|
func envOrDefaultBool(key string, defaultVal bool) bool {
|
||||||
v := os.Getenv(key)
|
v := strings.TrimSpace(strings.ToLower(os.Getenv(key)))
|
||||||
if v == "" {
|
if v == "" {
|
||||||
return defaultVal
|
return defaultVal
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -298,7 +298,7 @@ func (c *Client) GetAuthenticatedUser(ctx context.Context) (string, error) {
|
|||||||
|
|
||||||
// ListReviews returns all reviews on a pull request.
|
// ListReviews returns all reviews on a pull request.
|
||||||
func (c *Client) ListReviews(ctx context.Context, owner, repo string, number int) ([]Review, error) {
|
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,
|
c.baseURL,
|
||||||
url.PathEscape(owner),
|
url.PathEscape(owner),
|
||||||
url.PathEscape(repo),
|
url.PathEscape(repo),
|
||||||
|
|||||||
@@ -361,6 +361,9 @@ func TestListReviews(t *testing.T) {
|
|||||||
if r.URL.Path != "/api/v1/repos/owner/repo/pulls/5/reviews" {
|
if r.URL.Path != "/api/v1/repos/owner/repo/pulls/5/reviews" {
|
||||||
t.Errorf("unexpected path: %s", r.URL.Path)
|
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.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}]`))
|
w.Write([]byte(`[{"id":10,"user":{"login":"bot-a"},"state":"APPROVED","stale":false},{"id":11,"user":{"login":"bot-b"},"state":"REQUEST_CHANGES","stale":true}]`))
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user