Skip to content

Commit

Permalink
fix(internal/gapicgen): move breaking change indicator if present (#5452
Browse files Browse the repository at this point in the history
)

This was discovered processing 8e91ed1.
If a scope is present to be compliant with conventional commits the bang
must be after the scope.
  • Loading branch information
codyoss committed Feb 4, 2022
1 parent 93ccb57 commit e712df5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/gapicgen/git/git.go
Expand Up @@ -59,7 +59,15 @@ func FormatChanges(changes []*ChangeInfo, onlyGapicChanges bool) string {
if i := strings.Index(titleParts[0], "("); i > 0 {
titleParts[0] = titleParts[0][:i]
}
titleParts[0] = fmt.Sprintf("%s(%s)", titleParts[0], c.Package)

var breakChangeIndicator string
if strings.HasSuffix(titleParts[0], "!") {
// If the change is marked as breaking we need to move the
// bang to after the added scope.
titleParts[0] = titleParts[0][:len(titleParts[0])-1]
breakChangeIndicator = "!"
}
titleParts[0] = fmt.Sprintf("%s(%s)%s", titleParts[0], c.Package, breakChangeIndicator)
}
title = strings.Join(titleParts, ":")
}
Expand Down
5 changes: 5 additions & 0 deletions internal/gapicgen/git/git_test.go
Expand Up @@ -73,6 +73,11 @@ func TestFormatChanges(t *testing.T) {
changes: []*ChangeInfo{{Title: "fix: foo", Body: "bar", Package: "baz"}},
want: "\nChanges:\n\nfix(baz): foo\n bar\n\n",
},
{
name: "with package, breaking change",
changes: []*ChangeInfo{{Title: "feat!: foo", Body: "bar", Package: "baz"}},
want: "\nChanges:\n\nfeat(baz)!: foo\n bar\n\n",
},
{
name: "multiple changes",
changes: []*ChangeInfo{{Title: "fix: foo", Body: "bar", Package: "foo"}, {Title: "fix: baz", Body: "bar"}},
Expand Down

0 comments on commit e712df5

Please sign in to comment.