Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(internal/gapicgen): move breaking change indicator if present #5452

Merged
merged 1 commit into from Feb 4, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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