Skip to content

Commit beb0cb4

Browse files
authored
Prevent invalid semver version 0.0.x (#283)
1 parent fbee30c commit beb0cb4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/utils/change.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ describe('change', () => {
116116
const nextVersion = getNextVersionFromLabels('1.0.1-rc.2', config.user, changesWithMinor, true);
117117
expect(nextVersion).toBe('1.1.0-rc.0');
118118
});
119+
120+
it('should get 0.1.0 for first version with only bugfix', () => {
121+
const nextVersion = getNextVersionFromLabels('0.0.0', config.user, changesWithPatch, false);
122+
expect(nextVersion).toBe('0.1.0');
123+
});
119124
});
120125

121126
describe('changelog generation', () => {

src/utils/change.ts

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export function getNextVersionFromLabels(
1313
return null;
1414
}
1515

16+
if (semver.major(lastVersion) === 0 && semver.minor(lastVersion) === 0) {
17+
return semver.inc(lastVersion, 'minor');
18+
}
19+
1620
const changeLabels = config.changeTypes!.reduce(
1721
(acc, c) => {
1822
acc[c.bump].push(...c.labels);

0 commit comments

Comments
 (0)