Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions internal/cli/command/pull_requests/summarize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import (

"github.com/Tomas-vilte/MateCommit/internal/cli/completion_helper"
cfg "github.com/Tomas-vilte/MateCommit/internal/config"
"github.com/Tomas-vilte/MateCommit/internal/infrastructure/factory"
"github.com/Tomas-vilte/MateCommit/internal/domain/ports"
"github.com/Tomas-vilte/MateCommit/internal/ui"

"github.com/Tomas-vilte/MateCommit/internal/i18n"
"github.com/urfave/cli/v3"
)

type SummarizeCommand struct {
prFactory factory.PRServiceFactoryInterface
prService ports.PRService
}

func NewSummarizeCommand(prFactory factory.PRServiceFactoryInterface) *SummarizeCommand {
func NewSummarizeCommand(prService ports.PRService) *SummarizeCommand {
return &SummarizeCommand{
prFactory: prFactory,
prService: prService,
}
}

Expand All @@ -38,9 +38,8 @@ func (c *SummarizeCommand) CreateCommand(t *i18n.Translations, _ *cfg.Config) *c
},
ShellComplete: completion_helper.DefaultFlagComplete,
Action: func(ctx context.Context, cmd *cli.Command) error {
prService, err := c.prFactory.CreatePRService(ctx)
if err != nil {
return fmt.Errorf(t.GetMessage("error.pr_service_creation_error", 0, nil)+": %w", err)
if c.prService == nil {
return fmt.Errorf("%s", t.GetMessage("ai_missing.ai_missing_for_pr", 0, nil))
}
prNumber := cmd.Int("pr-number")
if prNumber == 0 {
Expand All @@ -52,7 +51,7 @@ func (c *SummarizeCommand) CreateCommand(t *i18n.Translations, _ *cfg.Config) *c
}))
spinner.Start()

summary, err := prService.SummarizePR(ctx, prNumber, func(msg string) {
summary, err := c.prService.SummarizePR(ctx, prNumber, func(msg string) {
spinner.Log(msg)
})
if err != nil {
Expand Down
Binary file added matecommit
Binary file not shown.
Loading