Compare commits

..

1 Commits

Author SHA1 Message Date
u80864958
1ba0e879f9 feat: add logs 2026-02-13 17:52:31 +01:00
2 changed files with 18 additions and 2 deletions

View File

@@ -49,6 +49,11 @@ type ReviewConfig struct {
type Config struct {
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-…`.
// Existing configuration files using the old flag names will need to be updated.
@@ -63,6 +68,7 @@ type Config struct {
}
func main() {
cfg := &Config{}
home, err := os.UserHomeDir()
if err != nil {
@@ -91,12 +97,22 @@ func main() {
case "error":
lvl = slog.LevelError
}
// Logs are sent to stderr so that stdout can be safely piped.
// The review output (fmt.Printf) stays on stdout unchanged.
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: lvl}))
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
provider := cfg.GitProvider
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",
c.File, c.Line, c.Message, "---")
if !s.disableComments {
if s.disableComments {
if err := s.git.AddComment(ctx, organisation, repo, prID, c); err != nil {
log.Printf("Failed to add comment: %v", err)
}