Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,17 @@ export const release = (cwd: string, { type, bumpEngine }: Options, deps: Deps)
continue;
}
git('checkout', '-q', '--detach', head);
if (!ok('cherry-pick', '-x', sha)) {

// a fix backported by hand under a different patch applies as nothing, so it's dropped
if (!ok('cherry-pick', '-x', '--empty=drop', sha)) {
git('cherry-pick', '--abort');
throw new Error(
`Backport of #${number} conflicts on ${branch}; backport it by hand or remove its "${BACKPORT_LABEL}" label`
);
}
head = git('rev-parse', 'HEAD');
console.log(`Backported #${number}`);
const picked = git('rev-parse', 'HEAD');
console.log(picked === head ? `Skipping #${number}: already on ${branch}` : `Backported #${number}`);
head = picked;
}
head = withEngine(head);
if (!git('rev-list', '-1', `${latest}..${head}`)) {
Expand Down
9 changes: 9 additions & 0 deletions test/release/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ describe('release', function () {
expect(refs()).to.equal(before);
});

it('skips a backport the branch already has under a different patch', () => {
run('minor');
picks = [{ number: 9, title: 'fix: b', sha: land('main', 'b.txt', 'b') }];
land('release-2.34', 'b.txt', 'old');
land('release-2.34', 'b.txt', 'b');
expect(run('patch')).to.deep.equal({ tag: 'v2.34.1', released: true });
expect(sh(remote, 'show', 'release-2.34:b.txt')).to.equal('b');
});

it('does nothing when there is nothing to release', () => {
run('minor');
const before = refs();
Expand Down
Loading