diff --git a/cmd/generate.go b/cmd/generate.go index c981aa7..db2af04 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -68,23 +68,27 @@ gh jira-changelog generate --config=".yaml" --from="v0.1.0" defer cancel() repoURL := repoURL(ctx) - var populator messages.Populator - if usePR { - populator, err = messages.NewPullRequestPopulator(fromRef, toRef, repoURL) - } else { - populator, err = messages.NewCommitPopulator(fromRef, toRef) - } - changelog := jira_changelog.Generator{ Client: jira.NewClient(jira.NewClientOptions(jira.Options{ jira.BaseURL: viper.GetString("base_url"), jira.ApiToken: viper.GetString("api_token"), jira.User: viper.GetString("email_id"), })), - Populator: populator, - FromRef: fromRef, - ToRef: toRef, - RepoURL: repoURL, + Populator: func() (populator messages.Populator) { + if usePR { + populator, err = messages.NewPullRequestPopulator(fromRef, toRef, repoURL) + } else { + populator, err = messages.NewCommitPopulator(fromRef, toRef) + } + return + }(), + FromRef: fromRef, + ToRef: toRef, + RepoURL: repoURL, + } + + if err != nil { + return err } slog.Info("Generating changelog", "From", fromRef, "To", toRef, "repoURL", repoURL) diff --git a/cmd/version.go b/cmd/version.go index 79f9194..f41370c 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -const version = "v0.3.2" +const version = "dev" var versionCmd = &cobra.Command{ Use: "version", diff --git a/pkg/jira_changelog/messages/pull_request_populator_test.go b/pkg/jira_changelog/messages/pull_request_populator_test.go index 564da40..dbf8a20 100644 --- a/pkg/jira_changelog/messages/pull_request_populator_test.go +++ b/pkg/jira_changelog/messages/pull_request_populator_test.go @@ -19,4 +19,3 @@ func TestRepoPath_WhenRepoURLIsInvalid(t *testing.T) { assert.NoError(t, err) assert.Equal(t, []string{"foo"}, result) } -