Skip to content

Commit 3f2cbd9

Browse files
authored
support auto-merge for pre-release bumps (#192)
1 parent 2010d20 commit 3f2cbd9

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export type AutoMergeOption = {
306306
/**
307307
* Only auto merge if the version bump match the filter
308308
*/
309-
versionBumpFilter?: ('major' | 'minor' | 'patch' | 'build')[];
309+
versionBumpFilter?: ('major' | 'minor' | 'patch' | 'build' | 'preRelease')[];
310310
};
311311

312312
export class Manifest {

src/version.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ export class Version {
8383
return `${this.major}.${this.minor}.${this.patch}${preReleasePart}${buildPart}`;
8484
}
8585

86-
compareBump(other: Version): 'major' | 'minor' | 'patch' | 'build' | 'none' {
86+
compareBump(
87+
other: Version
88+
): 'major' | 'minor' | 'patch' | 'build' | 'preRelease' | 'none' {
8789
if (this.major !== other.major) {
8890
return 'major';
8991
}
@@ -96,6 +98,9 @@ export class Version {
9698
if (this.build !== other.build) {
9799
return 'build';
98100
}
101+
if (this.preRelease !== other.preRelease) {
102+
return 'preRelease';
103+
}
99104
return 'none';
100105
}
101106
}

test/manifest.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,39 @@ describe('Manifest', () => {
16751675
);
16761676
});
16771677

1678+
it('should identify prerelease bumps as such', async () => {
1679+
const manifest = new Manifest(
1680+
github,
1681+
'main',
1682+
{
1683+
'.': {
1684+
releaseType: 'simple',
1685+
versioning: 'prerelease',
1686+
},
1687+
},
1688+
{
1689+
'.': Version.parse('0.1.0-alpha.28'),
1690+
}
1691+
);
1692+
const pullRequests = await manifest.buildPullRequests([], []);
1693+
expect(pullRequests).lengthOf(1);
1694+
const pullRequest = pullRequests[0];
1695+
expect(pullRequest.version?.toString()).to.eql('0.1.0-alpha.29');
1696+
expect(pullRequest.previousVersion?.toString()).to.eql(
1697+
'0.1.0-alpha.28'
1698+
);
1699+
expect(
1700+
pullRequest.version!.compareBump(pullRequest.previousVersion!)
1701+
).to.eql('preRelease');
1702+
// simple release type updates the changelog and version.txt
1703+
assertHasUpdate(pullRequest.updates, 'CHANGELOG.md');
1704+
assertHasUpdate(pullRequest.updates, 'version.txt');
1705+
assertHasUpdate(pullRequest.updates, '.release-please-manifest.json');
1706+
expect(pullRequest.headRefName).to.eql(
1707+
'release-please--branches--main'
1708+
);
1709+
});
1710+
16781711
it('should honour the manifestFile argument in Manifest.fromManifest', async () => {
16791712
const getFileContentsStub = sandbox
16801713
.stub(github, 'getFileContentsOnBranch')

0 commit comments

Comments
 (0)