Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/gapicgen/git/git.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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