Skip to content

Commit a57e5fd

Browse files
authored
fix: breaking change and feature pre-1.0 yields minor version bump (#2117)
Fixes #2109
1 parent 5ad9428 commit a57e5fd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

internal/semver/semver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ func DeriveNext(highestChange ChangeLevel, currentVersion string) (string, error
226226

227227
// Handle standard versions
228228
if currentSemVer.Major == 0 {
229-
if highestChange == Major {
230-
currentSemVer.Major++
231-
currentSemVer.Minor = 0
229+
// breaking change and feat result in minor bump for pre-1.0.0
230+
if highestChange == Major || highestChange == Minor {
231+
currentSemVer.Minor++
232232
currentSemVer.Patch = 0
233-
} else { // feat and fix result in a patch bump for pre-1.0.0
233+
} else {
234234
currentSemVer.Patch++
235235
}
236236
} else {

internal/semver/semver_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func TestDeriveNext(t *testing.T) {
191191
name: "pre-1.0.0 feat is patch bump",
192192
highestChange: Minor, // feat is minor
193193
currentVersion: "0.2.3",
194-
expectedVersion: "0.2.4",
194+
expectedVersion: "0.3.0",
195195
},
196196
{
197197
name: "pre-1.0.0 fix is patch bump",
@@ -200,10 +200,10 @@ func TestDeriveNext(t *testing.T) {
200200
expectedVersion: "0.2.4",
201201
},
202202
{
203-
name: "pre-1.0.0 breaking change is major bump",
203+
name: "pre-1.0.0 breaking change is minor bump",
204204
highestChange: Major,
205205
currentVersion: "0.2.3",
206-
expectedVersion: "1.0.0",
206+
expectedVersion: "0.3.0",
207207
},
208208
{
209209
name: "prerelease bump with numeric trailer",

0 commit comments

Comments
 (0)