From df058a927f2ab5f312d17c44b79d11a284db793d Mon Sep 17 00:00:00 2001 From: maulik13 Date: Mon, 22 Feb 2021 14:57:50 +0100 Subject: [PATCH] refactor(changelog): remove unused Version and Now fields, fixed spelling --- internal/changelog/changelog.go | 10 +++------- internal/changelog/changelog_test.go | 2 +- pkg/semanticrelease/semantic-release.go | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/changelog/changelog.go b/internal/changelog/changelog.go index 7df00bc..e77c7bd 100644 --- a/internal/changelog/changelog.go +++ b/internal/changelog/changelog.go @@ -68,8 +68,6 @@ type commitsContent struct { Commits map[string][]shared.AnalyzedCommit BreakingChanges []shared.AnalyzedCommit Order []string - Version string - Now time.Time Backtick string HasURL bool URL string @@ -93,11 +91,11 @@ func New(config *config.ReleaseConfig, rules []analyzer.Rule, releaseTime time.T } } -// GenerateChanglog from given commits -func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[shared.Release][]shared.AnalyzedCommit) (*shared.GeneratedChangelog, error) { +// GenerateChangelog from given commits +func (c *Changelog) GenerateChangelog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[shared.Release][]shared.AnalyzedCommit) (*shared.GeneratedChangelog, error) { commitsPerScope := map[string][]shared.AnalyzedCommit{} - commitsBreakingChange := []shared.AnalyzedCommit{} + var commitsBreakingChange []shared.AnalyzedCommit order := make([]string, 0) for _, rule := range c.rules { @@ -123,9 +121,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf } commitsContent := commitsContent{ - Version: templateConfig.Version, Commits: commitsPerScope, - Now: c.releaseTime, BreakingChanges: commitsBreakingChange, Backtick: "`", Order: order, diff --git a/internal/changelog/changelog_test.go b/internal/changelog/changelog_test.go index a5ad35c..65e60a9 100644 --- a/internal/changelog/changelog_test.go +++ b/internal/changelog/changelog_test.go @@ -249,7 +249,7 @@ func TestChangelog(t *testing.T) { for _, config := range testConfigs { t.Run(config.testCase, func(t *testing.T) { - generatedChangelog, err := cl.GenerateChanglog(templateConfig, config.analyzedCommits) + generatedChangelog, err := cl.GenerateChangelog(templateConfig, config.analyzedCommits) assert.Equalf(t, config.hasError, err != nil, "Testcase %s should have error: %t -> %s", config.testCase, config.hasError, err) assert.Equalf(t, config.result, generatedChangelog, "Testcase %s should have generated changelog", config.testCase) }) diff --git a/pkg/semanticrelease/semantic-release.go b/pkg/semanticrelease/semantic-release.go index 5eb174b..9221706 100644 --- a/pkg/semanticrelease/semantic-release.go +++ b/pkg/semanticrelease/semantic-release.go @@ -180,7 +180,7 @@ func (s *SemanticRelease) SetVersion(provider *ci.ProviderConfig, version string // GetChangelog from last version till now func (s *SemanticRelease) GetChangelog(releaseVersion *shared.ReleaseVersion) (*shared.GeneratedChangelog, error) { c := changelog.New(s.config, s.analyzer.GetRules(), time.Now()) - return c.GenerateChanglog(shared.ChangelogTemplateConfig{ + return c.GenerateChangelog(shared.ChangelogTemplateConfig{ Version: releaseVersion.Next.Version.String(), Hash: releaseVersion.Last.Commit, CommitURL: s.releaser.GetCommitURL(),