feat(cmd): wire --provider and --base-url flags into CLI (Phase 5) #106
@@ -179,9 +179,6 @@ func main() {
|
||||
ghBaseURL = "https://api.github.com"
|
||||
|
|
||||
}
|
||||
client = github.NewClient(*reviewerToken, ghBaseURL)
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Error: unhandled provider %q\n", *provider)
|
||||
os.Exit(1)
|
||||
}
|
||||
slog.Info("VCS client initialized", "provider", *provider)
|
||||
|
||||
|
sonnet-review-bot
commented
[NIT] The switch for VCS client initialization has no default branch (the provider validation switch above guarantees valid values, so this is technically safe), but adding a default: panic(...) or default: slog.Error(...); os.Exit(1) would make the invariant explicit and guard against future providers being added to the validation switch without a corresponding factory branch. **[NIT]** The switch for VCS client initialization has no default branch (the provider validation switch above guarantees valid values, so this is technically safe), but adding a default: panic(...) or default: slog.Error(...); os.Exit(1) would make the invariant explicit and guard against future providers being added to the validation switch without a corresponding factory branch.
|
||||
@@ -899,7 +896,6 @@ func extractSentinelName(body string) string {
|
||||
return name
|
||||
}
|
||||
|
||||
|
||||
// findAllOwnReviews returns all non-superseded reviews matching the sentinel.
|
||||
|
rodin marked this conversation as resolved
Outdated
sonnet-review-bot
commented
[NIT] There is a stray blank line before **[NIT]** There is a stray blank line before `// findAllOwnReviews returns all non-superseded reviews matching the sentinel.` after the `extractSentinelName` function body closing brace. Minor cosmetic issue.
|
||||
func findAllOwnReviews(reviews []vcs.Review, sentinel string) []vcs.Review {
|
||||
var result []vcs.Review
|
||||
|
||||
@@ -210,7 +210,6 @@ func TestBuildSupersededBodyShortSHA(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestHasSharedToken(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -646,8 +645,8 @@ func TestExtractSentinelName_EdgeCases(t *testing.T) {
|
||||
{"<!-- review-bot:sonnet --> rest", "sonnet"},
|
||||
{"<!-- review-bot:gpt-review --> rest", "gpt-review"},
|
||||
{"no sentinel here", "unknown"},
|
||||
{"<!-- review-bot:", "unknown"}, // prefix but no suffix
|
||||
{"prefix <!-- review-bot:abc --> end", "abc"}, // embedded in text
|
||||
{"<!-- review-bot:", "unknown"}, // prefix but no suffix
|
||||
{"prefix <!-- review-bot:abc --> end", "abc"}, // embedded in text
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
||||
@@ -386,6 +386,7 @@ func (c *Client) doRequestWithBody(ctx context.Context, method, reqURL string, r
|
||||
return c.doRequestCore(ctx, method, reqURL, opts)
|
||||
|
||||
|
gpt-review-bot
commented
[NIT] Minor formatting: there is an extra blank line between the closing brace of doRequestWithBody and the start of doJSONRequest that could be removed for consistency. **[NIT]** Minor formatting: there is an extra blank line between the closing brace of doRequestWithBody and the start of doJSONRequest that could be removed for consistency.
sonnet-review-bot
commented
[NIT] There is a spurious blank line before the closing brace of **[NIT]** There is a spurious blank line before the closing brace of `doRequestWithBody` (after `return c.doRequestCore(...)`). Minor formatting issue that gofmt would not flag since it's inside a function body, but it's visually inconsistent.
|
||||
}
|
||||
|
sonnet-review-bot
commented
[NIT] doJSONRequest is added but not yet called by any public methods in the diff (the github package has no PostReview/DismissReview/etc. visible in the diff). This is fine for an incremental PR, but it means the new helper is untested at the integration level. The unit tests for doJSONRequest itself are present and cover the retry path. **[NIT]** doJSONRequest is added but not yet called by any public methods in the diff (the github package has no PostReview/DismissReview/etc. visible in the diff). This is fine for an incremental PR, but it means the new helper is untested at the integration level. The unit tests for doJSONRequest itself are present and cover the retry path.
|
||||
|
||||
// doJSONRequest performs an HTTP request with a JSON body and returns the response body.
|
||||
// It delegates retry/backoff/429 handling to doRequestWithBody.
|
||||
|
sonnet-review-bot
commented
[MINOR] **[MINOR]** `doJSONRequest` does not retry on HTTP 429 like `doRequest` does. Since `PostReview` and `DismissReview` are write operations that can be rate-limited by GitHub, missing retry logic here could cause failures in high-traffic repos. Consider either adding retry logic or documenting that write operations are not retried.
|
||||
// This is a general-purpose helper used by any method that needs to send JSON payloads
|
||||
|
||||
@@ -355,7 +355,7 @@ func TestCapitalizeFirst(t *testing.T) {
|
||||
{"HELLO", "HELLO"},
|
||||
{"a", "A"},
|
||||
{"", ""},
|
||||
{"日本語", "日本語"}, // Non-ASCII: Japanese doesn't have case
|
||||
{"日本語", "日本語"}, // Non-ASCII: Japanese doesn't have case
|
||||
{"über", "Über"}, // German umlaut
|
||||
{"élève", "Élève"}, // French accent
|
||||
}
|
||||
|
||||
[NIT] When provider == github, base URL fallback logic duplicates the default already handled by github.NewClient("", ""). You can simplify by passing the possibly-empty baseURL and letting NewClient use its default.