0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-06-02 17:39:39 +02:00

fix: add missing processors and fix logging

This commit is contained in:
Robert Kaussow 2023-10-15 22:20:39 +02:00
parent ac9b7496c5
commit eb7bea48e2
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
3 changed files with 10 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/thegeeklab/git-sv/v2/sv"
"github.com/thegeeklab/git-sv/v2/sv/formatter"
"github.com/thegeeklab/git-sv/v2/templates"
)
const (
@ -61,8 +62,7 @@ type GitSV struct {
MessageProcessor sv.MessageProcessor
CommitProcessor sv.CommitProcessor
ReleasenotesProcessor sv.ReleaseNoteProcessor
OutputFormatter formatter.OutputFormatter
OutputFormatter formatter.OutputFormatter
}
// New constructor.
@ -72,6 +72,9 @@ func New() GitSV {
}
g.MessageProcessor = sv.NewMessageProcessor(g.Config.CommitMessage, g.Config.Branches)
g.CommitProcessor = sv.NewSemVerCommitProcessor(g.Config.Versioning, g.Config.CommitMessage)
g.ReleasenotesProcessor = sv.NewReleaseNoteProcessor(g.Config.ReleaseNotes)
g.OutputFormatter = formatter.NewOutputFormatter(templates.New(configDir))
return g
}

View File

@ -45,7 +45,7 @@ func ReleaseNotesHandler(g app.GitSV) cli.ActionFunc {
output, err := g.OutputFormatter.FormatReleaseNote(releasenote)
if err != nil {
return fmt.Errorf("could not format release notes, message: %w", err)
return fmt.Errorf("could not format release notes: %w", err)
}
fmt.Println(output)

View File

@ -32,10 +32,12 @@ func main() {
&cli.StringFlag{
Name: "log-level",
Usage: "log level",
Value: "info",
},
},
Before: func(ctx *cli.Context) error {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
lvl, err := zerolog.ParseLevel(ctx.String("log-level"))
if err != nil {
return err
@ -132,7 +134,7 @@ When flag range is "date", if "end" is YYYY-MM-DD the range will be inclusive.`,
},
}
if apperr := app.Run(os.Args); apperr != nil {
log.Fatal().Err(apperr).Msg("Execution error")
if err := app.Run(os.Args); err != nil {
log.Fatal().Err(err).Msg("Execution error")
}
}