diff --git a/Makefile b/Makefile index 57f750f..8a98e06 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # renovate: datasource=github-releases depName=mvdan/gofumpt -GOFUMPT_PACKAGE_VERSION := v0.5.0 +GOFUMPT_PACKAGE_VERSION := v0.6.0 # renovate: datasource=github-releases depName=golangci/golangci-lint -GOLANGCI_LINT_PACKAGE_VERSION := v1.55.2 +GOLANGCI_LINT_PACKAGE_VERSION := v1.56.1 EXECUTABLE := git-sv diff --git a/app/commands/changelog.go b/app/commands/changelog.go index ff798bf..a786569 100644 --- a/app/commands/changelog.go +++ b/app/commands/changelog.go @@ -45,7 +45,7 @@ func ChangelogFlags(settings *app.ChangelogSettings) []cli.Flag { //nolint:gocognit func ChangelogHandler(g app.GitSV, settings *app.ChangelogSettings) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { tags, err := g.Tags() if err != nil { return err diff --git a/app/commands/commitlog.go b/app/commands/commitlog.go index a48135f..363ade7 100644 --- a/app/commands/commitlog.go +++ b/app/commands/commitlog.go @@ -49,7 +49,7 @@ func CommitLogFlags(settings *app.CommitLogSettings) []cli.Flag { } func CommitLogHandler(g app.GitSV, settings *app.CommitLogSettings) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { var ( commits []sv.CommitLog err error diff --git a/app/commands/commitnotes.go b/app/commands/commitnotes.go index 91477f9..7643c2a 100644 --- a/app/commands/commitnotes.go +++ b/app/commands/commitnotes.go @@ -39,7 +39,7 @@ func CommitNotesFlags(settings *app.CommitNotesSettings) []cli.Flag { } func CommitNotesHandler(g app.GitSV, settings *app.CommitNotesSettings) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { var date time.Time lr, err := logRange(g, settings.Range, settings.Start, settings.End) diff --git a/app/commands/config.go b/app/commands/config.go index 1b382b5..cd7d152 100644 --- a/app/commands/config.go +++ b/app/commands/config.go @@ -9,7 +9,7 @@ import ( ) func ConfigDefaultHandler() cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { cfg := app.GetDefault() content, err := yaml.Marshal(&cfg) @@ -24,7 +24,7 @@ func ConfigDefaultHandler() cli.ActionFunc { } func ConfigShowHandler(cfg *app.Config) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { content, err := yaml.Marshal(cfg) if err != nil { return err diff --git a/app/commands/currentversion.go b/app/commands/currentversion.go index 22065d0..04383bd 100644 --- a/app/commands/currentversion.go +++ b/app/commands/currentversion.go @@ -9,7 +9,7 @@ import ( ) func CurrentVersionHandler(gsv app.GitSV) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { lastTag := gsv.LastTag() currentVer, err := sv.ToVersion(lastTag) diff --git a/app/commands/nextversion.go b/app/commands/nextversion.go index fb7e8ec..54c8db4 100644 --- a/app/commands/nextversion.go +++ b/app/commands/nextversion.go @@ -10,7 +10,7 @@ import ( ) func NextVersionHandler(g app.GitSV) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { lastTag := g.LastTag() currentVer, err := sv.ToVersion(lastTag) diff --git a/app/commands/releasenotes.go b/app/commands/releasenotes.go index 81f84e8..653b285 100644 --- a/app/commands/releasenotes.go +++ b/app/commands/releasenotes.go @@ -31,7 +31,7 @@ func ReleaseNotesFlags(settings *app.ReleaseNotesSettings) []cli.Flag { } func ReleaseNotesHandler(g app.GitSV, settings *app.ReleaseNotesSettings) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { var ( commits []sv.CommitLog rnVersion *semver.Version diff --git a/app/commands/tag.go b/app/commands/tag.go index fa1e03e..e39d8da 100644 --- a/app/commands/tag.go +++ b/app/commands/tag.go @@ -26,7 +26,7 @@ func TagFlags(settings *app.TagSettings) []cli.Flag { } func TagHandler(g app.GitSV, settings *app.TagSettings) cli.ActionFunc { - return func(c *cli.Context) error { + return func(_ *cli.Context) error { lastTag := g.LastTag() currentVer, err := sv.ToVersion(lastTag) diff --git a/app/config_test.go b/app/config_test.go index 2fdfc62..ffd8808 100644 --- a/app/config_test.go +++ b/app/config_test.go @@ -148,6 +148,7 @@ func Test_merge(t *testing.T) { if err := merge(&tt.dst, tt.src); (err != nil) != tt.wantErr { t.Errorf("merge() error = %v, wantErr %v", err, tt.wantErr) } + if !reflect.DeepEqual(tt.dst, tt.want) { t.Errorf("merge() = %v, want %v", tt.dst, tt.want) } diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index c53b454..38ec620 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -38,7 +38,7 @@ func main() { Destination: &gsv.Settings.LogLevel, }, }, - Before: func(ctx *cli.Context) error { + Before: func(_ *cli.Context) error { lvl, err := zerolog.ParseLevel(gsv.Settings.LogLevel) if err != nil { return err diff --git a/sv/commit_test.go b/sv/commit_test.go index 73aad75..1f4ce43 100644 --- a/sv/commit_test.go +++ b/sv/commit_test.go @@ -115,9 +115,11 @@ func TestSemVerCommitProcessor_NextVersion(t *testing.T) { }, CommitMessageConfig{Types: []string{"major", "minor", "patch", "none"}}) got, gotUpdated := p.NextVersion(tt.version, tt.commits) + if !reflect.DeepEqual(got, tt.want) { t.Errorf("SemVerCommitProcessor.NextVersion() Version = %v, want %v", got, tt.want) } + if tt.wantUpdated != gotUpdated { t.Errorf("SemVerCommitProcessor.NextVersion() Updated = %v, want %v", gotUpdated, tt.wantUpdated) } @@ -144,6 +146,7 @@ func TestToVersion(t *testing.T) { return } + if !reflect.DeepEqual(got, tt.want) { t.Errorf("ToVersion() = %v, want %v", got, tt.want) } diff --git a/sv/formatter/formatter_test.go b/sv/formatter/formatter_test.go index ecffc46..ec39265 100644 --- a/sv/formatter/formatter_test.go +++ b/sv/formatter/formatter_test.go @@ -114,6 +114,7 @@ func Test_checkTemplatesExecution(t *testing.T) { for _, tt := range tests { t.Run(tt.template, func(t *testing.T) { var b bytes.Buffer + err := tpls.ExecuteTemplate(&b, tt.template, tt.variables) if err != nil { t.Errorf("invalid template err = %v", err) diff --git a/sv/message.go b/sv/message.go index c7a1cea..483a9e5 100644 --- a/sv/message.go +++ b/sv/message.go @@ -392,6 +392,7 @@ func hasFooter(message string) bool { if lines > 0 && r.MatchString(scanner.Text()) { return true } + lines++ } diff --git a/sv/message_test.go b/sv/message_test.go index 58bde82..8349689 100644 --- a/sv/message_test.go +++ b/sv/message_test.go @@ -385,6 +385,7 @@ func TestBaseMessageProcessor_Enhance(t *testing.T) { return } + if got != tt.want { t.Errorf("BaseMessageProcessor.Enhance() = %v, want %v", got, tt.want) } @@ -416,6 +417,7 @@ func TestBaseMessageProcessor_IssueID(t *testing.T) { return } + if got != tt.want { t.Errorf("BaseMessageProcessor.IssueID() = %v, want %v", got, tt.want) } @@ -781,9 +783,11 @@ func TestBaseMessageProcessor_Format(t *testing.T) { if got != tt.wantHeader { t.Errorf("BaseMessageProcessor.Format() header got = %v, want %v", got, tt.wantHeader) } + if got1 != tt.wantBody { t.Errorf("BaseMessageProcessor.Format() body got = %v, want %v", got1, tt.wantBody) } + if got2 != tt.wantFooter { t.Errorf("BaseMessageProcessor.Format() footer got = %v, want %v", got2, tt.wantFooter) } @@ -815,6 +819,7 @@ func Test_splitCommitMessageContent(t *testing.T) { if got != tt.wantSubject { t.Errorf("splitCommitMessageContent() subject got = %v, want %v", got, tt.wantSubject) } + if got1 != tt.wantBody { t.Errorf("splitCommitMessageContent() body got1 = [%v], want [%v]", got1, tt.wantBody) } @@ -842,12 +847,15 @@ func Test_parseSubjectMessage(t *testing.T) { if ctype != tt.wantType { t.Errorf("parseSubjectMessage() type got = %v, want %v", ctype, tt.wantType) } + if scope != tt.wantScope { t.Errorf("parseSubjectMessage() scope got = %v, want %v", scope, tt.wantScope) } + if description != tt.wantDescription { t.Errorf("parseSubjectMessage() description got = %v, want %v", description, tt.wantDescription) } + if hasBreakingChange != tt.wantHasBreakingChange { t.Errorf("parseSubjectMessage() hasBreakingChange got = %v, want %v", hasBreakingChange, tt.wantHasBreakingChange) } @@ -927,6 +935,7 @@ func Test_prepareHeader(t *testing.T) { if tt.wantError && err == nil { t.Errorf("prepareHeader() err got = %v, want not nil", err) } + if header != tt.wantHeader { t.Errorf("prepareHeader() header got = %v, want %v", header, tt.wantHeader) }