Compare commits

..

1 Commits

Author SHA1 Message Date
u80864958
2e12c39786 feat: add logs 2026-02-13 18:04:09 +01:00
2 changed files with 2 additions and 18 deletions

View File

@@ -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 == "" {

View File

@@ -73,7 +73,7 @@ func (s *Service) MakeReview(ctx context.Context, organisation string, repo stri
fmt.Printf("File: %s\nLine: %d\nMessage: %s\n%s\n", fmt.Printf("File: %s\nLine: %d\nMessage: %s\n%s\n",
c.File, c.Line, c.Message, "---") c.File, c.Line, c.Message, "---")
if s.disableComments { if !s.disableComments {
if err := s.git.AddComment(ctx, organisation, repo, prID, c); err != nil { if err := s.git.AddComment(ctx, organisation, repo, prID, c); err != nil {
log.Printf("Failed to add comment: %v", err) log.Printf("Failed to add comment: %v", err)
} }