feat: correctly implement bitbucket & add OpenAIAdapter

This commit is contained in:
u80864958
2026-02-13 13:54:57 +01:00
parent b67125024c
commit 3f006f359b
13 changed files with 409 additions and 91 deletions

View File

@@ -20,8 +20,8 @@ func New(chat ChatAdapter, git GitAdapter) *Service {
}
type GitAdapter interface {
GetDiff(owner, repo string, prID int) (io.Reader, error)
AddComment(owner, repo string, prID int, comment Comment) error
GetDiff(ctx context.Context, owner, repo string, prID int) (io.ReadCloser, error)
AddComment(ctx context.Context, owner, repo string, prID int, comment Comment) error
}
type ChatAdapter interface {

View File

@@ -8,7 +8,8 @@ import (
func (s *Service) MakeReview(ctx context.Context, organisation string, repo string, prID int) error {
// Fetch Diff using positional args from shared RepoArgs
diff, err := s.git.GetDiff(organisation, repo, prID)
diff, err := s.git.GetDiff(ctx, organisation, repo, prID)
defer diff.Close()
if err != nil {
return fmt.Errorf("error fetching diff: %w", err)
}
@@ -25,7 +26,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 err := s.git.AddComment(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)
}
}