feat: add logs
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package pierre
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -19,6 +21,7 @@ type Comment struct {
|
||||
}
|
||||
|
||||
func (s *Service) judgePR(ctx context.Context, diff io.Reader) (comments []Comment, err error) {
|
||||
slog.Info("judgePR started")
|
||||
diffBytes, err := io.ReadAll(diff)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read diff: %w", err)
|
||||
@@ -81,6 +84,7 @@ If project guidelines are provided, treat them as hard rules that must be respec
|
||||
for _, v := range unique {
|
||||
comments = append(comments, v)
|
||||
}
|
||||
slog.Info("judgePR finished", "comments", len(comments))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -69,13 +69,11 @@ func (s *Service) MakeReview(ctx context.Context, organisation string, repo stri
|
||||
for _, c := range comments {
|
||||
c.Message = fmt.Sprintf("%s (Generated by: %s)", c.Message, model)
|
||||
|
||||
if s.disableComments {
|
||||
// Dry‑run: just log what would have been posted.
|
||||
log.Printf("dry‑run: %s:%d => %s", c.File, c.Line, c.Message)
|
||||
} else {
|
||||
// Normal mode: print to stdout and post the comment to the VCS.
|
||||
fmt.Printf("File: %s\nLine: %d\nMessage: %s\n%s\n",
|
||||
c.File, c.Line, c.Message, "---")
|
||||
// Normal mode: print to stdout and post the comment to the VCS.
|
||||
fmt.Printf("File: %s\nLine: %d\nMessage: %s\n%s\n",
|
||||
c.File, c.Line, c.Message, "---")
|
||||
|
||||
if !s.disableComments {
|
||||
if err := s.git.AddComment(ctx, organisation, repo, prID, c); err != nil {
|
||||
log.Printf("Failed to add comment: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user