|
|
|
@@ -49,11 +49,6 @@ type ReviewConfig struct {
|
|
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
type Config struct {
|
|
|
|
LogLevel string `help:"Log verbosity: debug, info, warn, error"`
|
|
|
|
LogLevel string `help:"Log verbosity: debug, info, warn, error"`
|
|
|
|
// Deprecated flags (no prefix). Retained for backward compatibility.
|
|
|
|
|
|
|
|
// These will be mapped to the embedded ReviewConfig if provided.
|
|
|
|
|
|
|
|
MaxChunkSize int `help:"Deprecated: use --review-max-chunk-size"`
|
|
|
|
|
|
|
|
Guidelines []string `help:"Deprecated: use --review-guidelines" sep:","`
|
|
|
|
|
|
|
|
DisableComments bool `help:"Deprecated: use --review-disable-comments"`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Embedding ReviewConfig with a prefix changes flag names to `--review-…`.
|
|
|
|
// Embedding ReviewConfig with a prefix changes flag names to `--review-…`.
|
|
|
|
// Existing configuration files using the old flag names will need to be updated.
|
|
|
|
// Existing configuration files using the old flag names will need to be updated.
|
|
|
|
@@ -68,7 +63,6 @@ type Config struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
|
|
|
|
cfg := &Config{}
|
|
|
|
cfg := &Config{}
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
home, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
@@ -97,22 +91,12 @@ func main() {
|
|
|
|
case "error":
|
|
|
|
case "error":
|
|
|
|
lvl = slog.LevelError
|
|
|
|
lvl = slog.LevelError
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Logs are sent to stderr so that stdout can be safely piped.
|
|
|
|
// Logs are sent to stderr so that stdout can be safely piped.
|
|
|
|
// The review output (fmt.Printf) stays on stdout unchanged.
|
|
|
|
// The review output (fmt.Printf) stays on stdout unchanged.
|
|
|
|
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: lvl}))
|
|
|
|
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: lvl}))
|
|
|
|
slog.SetDefault(logger)
|
|
|
|
slog.SetDefault(logger)
|
|
|
|
|
|
|
|
|
|
|
|
// Backwards compatibility: map deprecated flag values (if any) to the embedded ReviewConfig.
|
|
|
|
|
|
|
|
if cfg.MaxChunkSize != 0 {
|
|
|
|
|
|
|
|
cfg.Review.MaxChunkSize = cfg.MaxChunkSize
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(cfg.Guidelines) > 0 {
|
|
|
|
|
|
|
|
cfg.Review.Guidelines = cfg.Guidelines
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if cfg.DisableComments {
|
|
|
|
|
|
|
|
cfg.Review.DisableComments = cfg.DisableComments
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Auto-detect provider
|
|
|
|
// Auto-detect provider
|
|
|
|
provider := cfg.GitProvider
|
|
|
|
provider := cfg.GitProvider
|
|
|
|
if provider == "" {
|
|
|
|
if provider == "" {
|
|
|
|
|