Skip to content

Commit

Permalink
fix: breaking change on major version zero only bumps minor (#93)
Browse files Browse the repository at this point in the history
Co-authored-by: Gauthier Roebroeck <gauthier.roebroeck@episodesix.com>
  • Loading branch information
gotson and Gauthier Roebroeck committed Mar 7, 2023
1 parent ce0c298 commit 9c4dacb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/svu/svu.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func isPatch(log string) bool {

func FindNext(current *semver.Version, forcePatchIncrement bool, log string) semver.Version {
if isBreaking(log) {
if current.Major() == 0 {
return current.IncMinor()
}
return current.IncMajor()
}

Expand Down
6 changes: 6 additions & 0 deletions internal/svu/svu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ func TestIsPatch(t *testing.T) {
}

func TestFindNext(t *testing.T) {
version0a := semver.MustParse("v0.4.5")
version0b := semver.MustParse("v0.5.5")
version1 := semver.MustParse("v1.2.3")
version2 := semver.MustParse("v2.4.12")
version3 := semver.MustParse("v3.4.5-beta34+ads")
for expected, next := range map[string]semver.Version{
"v0.4.5": FindNext(version0a, false, "chore: should do nothing"),
"v0.4.6": FindNext(version0a, false, "fix: inc patch"),
"v0.5.0": FindNext(version0a, false, "feat: inc minor"),
"v0.6.0": FindNext(version0b, false, "feat!: inc minor"),
"v1.2.3": FindNext(version1, false, "chore: should do nothing"),
"v1.2.4": FindNext(version1, true, "chore: is forcing patch, so should inc patch"),
"v1.3.0": FindNext(version1, false, "feat: inc major"),
Expand Down

0 comments on commit 9c4dacb

Please sign in to comment.