You've already forked go-semantic-release
fix(cache): save commits to cache to avoid empty changelog
This commit is contained in:
@@ -34,8 +34,8 @@ introduced by commit:
|
||||
`
|
||||
|
||||
type changelogContent struct {
|
||||
Commits map[string][]analyzer.AnalyzedCommit
|
||||
BreakingChanges []analyzer.AnalyzedCommit
|
||||
Commits map[string][]shared.AnalyzedCommit
|
||||
BreakingChanges []shared.AnalyzedCommit
|
||||
Order []string
|
||||
Version string
|
||||
Now time.Time
|
||||
@@ -49,6 +49,7 @@ type Changelog struct {
|
||||
config *config.ReleaseConfig
|
||||
rules []analyzer.Rule
|
||||
releaseTime time.Time
|
||||
log *log.Entry
|
||||
}
|
||||
|
||||
//New Changelog struct for generating changelog from commits
|
||||
@@ -57,18 +58,19 @@ func New(config *config.ReleaseConfig, rules []analyzer.Rule, releaseTime time.T
|
||||
config: config,
|
||||
rules: rules,
|
||||
releaseTime: releaseTime,
|
||||
log: log.WithField("changelog", config.CommitFormat),
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateChanglog from given commits
|
||||
func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[analyzer.Release][]analyzer.AnalyzedCommit) (*shared.GeneratedChangelog, error) {
|
||||
func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConfig, analyzedCommits map[shared.Release][]shared.AnalyzedCommit) (*shared.GeneratedChangelog, error) {
|
||||
|
||||
commitsPerScope := map[string][]analyzer.AnalyzedCommit{}
|
||||
commitsBreakingChange := []analyzer.AnalyzedCommit{}
|
||||
commitsPerScope := map[string][]shared.AnalyzedCommit{}
|
||||
commitsBreakingChange := []shared.AnalyzedCommit{}
|
||||
order := make([]string, 0)
|
||||
|
||||
for _, rule := range c.rules {
|
||||
log.Debugf("Add %s to list", rule.TagString)
|
||||
c.log.Tracef("Add %s to list", rule.TagString)
|
||||
if rule.Changelog || c.config.Changelog.PrintAll {
|
||||
order = append(order, rule.TagString)
|
||||
}
|
||||
@@ -82,7 +84,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
|
||||
continue
|
||||
}
|
||||
if _, ok := commitsPerScope[commit.TagString]; !ok {
|
||||
commitsPerScope[commit.TagString] = make([]analyzer.AnalyzedCommit, 0)
|
||||
commitsPerScope[commit.TagString] = make([]shared.AnalyzedCommit, 0)
|
||||
}
|
||||
commitsPerScope[commit.TagString] = append(commitsPerScope[commit.TagString], commit)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/Nightapes/go-semantic-release/internal/analyzer"
|
||||
"github.com/Nightapes/go-semantic-release/internal/changelog"
|
||||
"github.com/Nightapes/go-semantic-release/internal/gitutil"
|
||||
"github.com/Nightapes/go-semantic-release/internal/shared"
|
||||
"github.com/Nightapes/go-semantic-release/pkg/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -23,16 +22,16 @@ func TestChangelog(t *testing.T) {
|
||||
|
||||
testConfigs := []struct {
|
||||
testCase string
|
||||
analyzedCommits map[analyzer.Release][]analyzer.AnalyzedCommit
|
||||
analyzedCommits map[shared.Release][]shared.AnalyzedCommit
|
||||
result *shared.GeneratedChangelog
|
||||
hasError bool
|
||||
}{
|
||||
{
|
||||
testCase: "feat",
|
||||
analyzedCommits: map[analyzer.Release][]analyzer.AnalyzedCommit{
|
||||
"minor": []analyzer.AnalyzedCommit{
|
||||
analyzer.AnalyzedCommit{
|
||||
Commit: gitutil.Commit{
|
||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||
"minor": []shared.AnalyzedCommit{
|
||||
shared.AnalyzedCommit{
|
||||
Commit: shared.Commit{
|
||||
Message: "feat(test): my first commit",
|
||||
Author: "me",
|
||||
Hash: "12345667",
|
||||
@@ -53,10 +52,10 @@ func TestChangelog(t *testing.T) {
|
||||
},
|
||||
{
|
||||
testCase: "feat breaking change",
|
||||
analyzedCommits: map[analyzer.Release][]analyzer.AnalyzedCommit{
|
||||
"minor": []analyzer.AnalyzedCommit{
|
||||
analyzer.AnalyzedCommit{
|
||||
Commit: gitutil.Commit{
|
||||
analyzedCommits: map[shared.Release][]shared.AnalyzedCommit{
|
||||
"minor": []shared.AnalyzedCommit{
|
||||
shared.AnalyzedCommit{
|
||||
Commit: shared.Commit{
|
||||
Message: "feat(test): my first commit",
|
||||
Author: "me",
|
||||
Hash: "12345667",
|
||||
@@ -67,8 +66,8 @@ func TestChangelog(t *testing.T) {
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
},
|
||||
analyzer.AnalyzedCommit{
|
||||
Commit: gitutil.Commit{
|
||||
shared.AnalyzedCommit{
|
||||
Commit: shared.Commit{
|
||||
Message: "feat(test): my first break: BREAKING CHANGE: change api to v2",
|
||||
Author: "me",
|
||||
Hash: "12345668",
|
||||
|
||||
Reference in New Issue
Block a user