feat(cmd): wire --provider and --base-url flags into CLI (Phase 5) #106
@@ -85,8 +85,8 @@ func main() {
|
|||||||
aicoreResourceGroup := flag.String("aicore-resource-group", envOrDefault("AICORE_RESOURCE_GROUP", "default"), "SAP AI Core resource group (for provider=aicore)")
|
aicoreResourceGroup := flag.String("aicore-resource-group", envOrDefault("AICORE_RESOURCE_GROUP", "default"), "SAP AI Core resource group (for provider=aicore)")
|
||||||
|
rodin marked this conversation as resolved
|
|||||||
|
|
||||||
// Backward-compatible alias: --gitea-url shares vcsURL's pointer (last flag wins).
|
// Backward-compatible alias: --gitea-url shares vcsURL's pointer (last flag wins).
|
||||||
|
sonnet-review-bot
commented
[MINOR] The **[MINOR]** The `--gitea-url` backward-compatible alias is registered with `flag.StringVar(vcsURL, "gitea-url", *vcsURL, ...)` where `*vcsURL` is the default value captured at the moment of the call — before `flag.Parse()`. This is correct as written because `*vcsURL` is still the default string at that point, but it creates a subtle ordering dependency: if `vcsURL` ever acquired a non-default value between its declaration and this `flag.StringVar` call (e.g., if any code ran between them), the alias would get a stale default. The comment acknowledges this (`Must stay after vcsURL declaration and before flag.Parse()`), but the fragility is worth noting. A cleaner pattern would be `flag.StringVar(vcsURL, "gitea-url", "", "...")` or extracting the default value to a named constant.
|
|||||||
// Must stay after vcsURL declaration and before flag.Parse().
|
// Shares vcsURL pointer; empty default avoids ordering dependency with vcsURL declaration.
|
||||||
flag.StringVar(vcsURL, "gitea-url", *vcsURL, "Deprecated: use --vcs-url instead")
|
flag.StringVar(vcsURL, "gitea-url", "", "Deprecated: use --vcs-url instead")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ func main() {
|
|||||||
case vcs.ProviderGitea:
|
case vcs.ProviderGitea:
|
||||||
giteaClient := gitea.NewClient(*vcsURL, *reviewerToken)
|
giteaClient := gitea.NewClient(*vcsURL, *reviewerToken)
|
||||||
client = gitea.NewAdapter(giteaClient)
|
client = gitea.NewAdapter(giteaClient)
|
||||||
case vcs.ProviderGithub:
|
case vcs.ProviderGitHub:
|
||||||
client = github.NewClient(*reviewerToken, *baseURL)
|
client = github.NewClient(*reviewerToken, *baseURL)
|
||||||
default:
|
default:
|
||||||
panic("unreachable: provider validation should have caught " + vcsProvider.String())
|
panic("unreachable: provider validation should have caught " + vcsProvider.String())
|
||||||
@@ -501,7 +501,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slog.Warn("provider does not support review superseding", "provider", vcsProvider)
|
slog.Error("provider does not support review superseding", "provider", vcsProvider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -721,8 +721,6 @@ func validateWorkspacePath(path, pathName string) (string, error) {
|
|||||||
return resolvedPath, nil
|
return resolvedPath, nil
|
||||||
|
sonnet-review-bot
commented
[NIT] There is a dangling comment fragment: **[NIT]** There is a dangling comment fragment: `// with collapsed original content and the commit it was evaluated against.` — this is the second half of the `buildSupersededBody` doc comment that was removed when the function moved to `gitea/adapter.go`. The first line of the doc comment (`// buildSupersededBody creates the body for a superseded review: struck-through banner`) was deleted but this trailing line was left orphaned. It should be removed.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// with collapsed original content and the commit it was evaluated against.
|
|
||||||
|
|
||||||
// hasSharedToken detects if another review-bot role posted under the same
|
// hasSharedToken detects if another review-bot role posted under the same
|
||||||
// VCS user. This indicates misconfiguration where two roles share a token
|
// VCS user. This indicates misconfiguration where two roles share a token
|
||||||
// instead of having separate accounts. Returns true if shared token
|
// instead of having separate accounts. Returns true if shared token
|
||||||
|
|||||||
@@ -282,7 +282,9 @@ func (a *Adapter) SupersedeReviews(ctx context.Context, owner, repo string, prNu
|
|||||||
if c.ID == 0 {
|
if c.ID == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_ = underlying.ResolveComment(ctx, owner, repo, c.ID)
|
if err := underlying.ResolveComment(ctx, owner, repo, c.ID); err != nil {
|
||||||
|
slog.Debug("could not resolve inline comment", "comment_id", c.ID, "error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ type VCSProvider string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ProviderGitea VCSProvider = "gitea"
|
ProviderGitea VCSProvider = "gitea"
|
||||||
ProviderGithub VCSProvider = "github"
|
ProviderGitHub VCSProvider = "github"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Valid reports whether p is a known VCS provider.
|
// Valid reports whether p is a known VCS provider.
|
||||||
func (p VCSProvider) Valid() bool {
|
func (p VCSProvider) Valid() bool {
|
||||||
switch p {
|
switch p {
|
||||||
case ProviderGitea, ProviderGithub:
|
case ProviderGitea, ProviderGitHub:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|||||||
[NIT] The
--gitea-urlalias comment block is long (12 lines) and explains a subtle flag.StringVar trick. Consider extracting the alias registration to a small helper or at minimum shortening the comment to the key invariant:flag.StringVar shares the pointer, so whichever flag is set last wins.The current comment is accurate but its length makes it easy to miss the ORDERING constraint.