refactor(changelog): remove unused Version and Now fields, fixed spelling

This commit is contained in:
maulik13
2021-02-22 14:57:50 +01:00
committed by Felix Wiedmann
parent 5a58d039fb
commit df058a927f
3 changed files with 5 additions and 9 deletions

View File

@@ -68,8 +68,6 @@ type commitsContent struct {
Commits map[string][]shared.AnalyzedCommit Commits map[string][]shared.AnalyzedCommit
BreakingChanges []shared.AnalyzedCommit BreakingChanges []shared.AnalyzedCommit
Order []string Order []string
Version string
Now time.Time
Backtick string Backtick string
HasURL bool HasURL bool
URL string URL string
@@ -93,11 +91,11 @@ func New(config *config.ReleaseConfig, rules []analyzer.Rule, releaseTime time.T
} }
} }
// GenerateChanglog from given commits // GenerateChangelog from given commits
func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[shared.Release][]shared.AnalyzedCommit) (*shared.GeneratedChangelog, error) { func (c *Changelog) GenerateChangelog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[shared.Release][]shared.AnalyzedCommit) (*shared.GeneratedChangelog, error) {
commitsPerScope := map[string][]shared.AnalyzedCommit{} commitsPerScope := map[string][]shared.AnalyzedCommit{}
commitsBreakingChange := []shared.AnalyzedCommit{} var commitsBreakingChange []shared.AnalyzedCommit
order := make([]string, 0) order := make([]string, 0)
for _, rule := range c.rules { for _, rule := range c.rules {
@@ -123,9 +121,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
} }
commitsContent := commitsContent{ commitsContent := commitsContent{
Version: templateConfig.Version,
Commits: commitsPerScope, Commits: commitsPerScope,
Now: c.releaseTime,
BreakingChanges: commitsBreakingChange, BreakingChanges: commitsBreakingChange,
Backtick: "`", Backtick: "`",
Order: order, Order: order,

View File

@@ -249,7 +249,7 @@ func TestChangelog(t *testing.T) {
for _, config := range testConfigs { for _, config := range testConfigs {
t.Run(config.testCase, func(t *testing.T) { 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.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) assert.Equalf(t, config.result, generatedChangelog, "Testcase %s should have generated changelog", config.testCase)
}) })

View File

@@ -180,7 +180,7 @@ func (s *SemanticRelease) SetVersion(provider *ci.ProviderConfig, version string
// GetChangelog from last version till now // GetChangelog from last version till now
func (s *SemanticRelease) GetChangelog(releaseVersion *shared.ReleaseVersion) (*shared.GeneratedChangelog, error) { func (s *SemanticRelease) GetChangelog(releaseVersion *shared.ReleaseVersion) (*shared.GeneratedChangelog, error) {
c := changelog.New(s.config, s.analyzer.GetRules(), time.Now()) 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(), Version: releaseVersion.Next.Version.String(),
Hash: releaseVersion.Last.Commit, Hash: releaseVersion.Last.Commit,
CommitURL: s.releaser.GetCommitURL(), CommitURL: s.releaser.GetCommitURL(),