You've already forked go-semantic-release
feat(analyzer): update AnalyzedCommit to add flexibility in parsing a message
This provides flexibility of parsing and rendering structured messages with more detail in the changelog and helps extract metadata from the message. The new structure can be used to split a message in multiple blocks (e.g. footer)
This commit is contained in:
@@ -110,7 +110,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
|
||||
for _, commits := range analyzedCommits {
|
||||
for _, commit := range commits {
|
||||
if commit.Print {
|
||||
if commit.ParsedBreakingChangeMessage != "" {
|
||||
if commit.IsBreaking {
|
||||
commitsBreakingChange = append(commitsBreakingChange, commit)
|
||||
continue
|
||||
}
|
||||
@@ -142,6 +142,7 @@ func (c *Changelog) GenerateChanglog(templateConfig shared.ChangelogTemplateConf
|
||||
HasDockerLatest: c.config.Changelog.Docker.Latest,
|
||||
DockerRepository: c.config.Changelog.Docker.Repository,
|
||||
}
|
||||
|
||||
template := defaultCommitListSubTemplate + defaultChangelog
|
||||
if c.config.Changelog.TemplatePath != "" {
|
||||
content, err := ioutil.ReadFile(c.config.Changelog.TemplatePath)
|
||||
|
||||
@@ -41,6 +41,8 @@ func TestChangelog(t *testing.T) {
|
||||
Tag: "feat",
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
Subject: "my first commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -64,6 +66,8 @@ func TestChangelog(t *testing.T) {
|
||||
Tag: "feat",
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
Subject: "my first commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -88,6 +92,8 @@ func TestChangelog(t *testing.T) {
|
||||
Tag: "feat",
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
Subject: "my first commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
{
|
||||
Commit: shared.Commit{
|
||||
@@ -101,6 +107,15 @@ func TestChangelog(t *testing.T) {
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
ParsedBreakingChangeMessage: "change api to v2",
|
||||
IsBreaking: true,
|
||||
Subject: "my first break",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{
|
||||
"body" : { shared.MessageBlock{
|
||||
Label: "BREAKING CHANGE",
|
||||
Content: "change api to v2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -126,6 +141,15 @@ func TestChangelog(t *testing.T) {
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
ParsedBreakingChangeMessage: "hey from the change",
|
||||
IsBreaking: true,
|
||||
Subject: "my first break",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{
|
||||
"body" : { shared.MessageBlock{
|
||||
Label: "BREAKING CHANGE",
|
||||
Content: "hey from the change",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Commit: shared.Commit{
|
||||
@@ -138,6 +162,8 @@ func TestChangelog(t *testing.T) {
|
||||
Tag: "feat",
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
Subject: "my first commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
{
|
||||
Commit: shared.Commit{
|
||||
@@ -150,10 +176,12 @@ func TestChangelog(t *testing.T) {
|
||||
Tag: "feat",
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
Subject: "my second commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
{
|
||||
Commit: shared.Commit{
|
||||
Message: "feat: my new commit \n\nmy first break: BREAKING CHANGE: change api to v2",
|
||||
Message: "feat: my new commit \n\nBREAKING CHANGE: change api to v2",
|
||||
Author: "me",
|
||||
Hash: "12345668",
|
||||
},
|
||||
@@ -163,6 +191,14 @@ func TestChangelog(t *testing.T) {
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
ParsedBreakingChangeMessage: "change api to v2",
|
||||
IsBreaking: true,
|
||||
Subject: "my new commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{
|
||||
"body": { shared.MessageBlock{
|
||||
Label: "BREAKING CHANGE",
|
||||
Content: "change api to v2",
|
||||
}},
|
||||
},
|
||||
},
|
||||
{
|
||||
Commit: shared.Commit{
|
||||
@@ -176,6 +212,9 @@ func TestChangelog(t *testing.T) {
|
||||
TagString: "Features",
|
||||
Print: true,
|
||||
ParsedBreakingChangeMessage: "my next commit",
|
||||
IsBreaking: true,
|
||||
Subject: "my next commit",
|
||||
MessageBlocks: map[string][]shared.MessageBlock{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user