Skip to content

Commit 5b3296a

Browse files
authored
fix: borrow generateAmendedMessage in CherryPick (#1125)
1 parent 72bf756 commit 5b3296a

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

‎lib/cherry_pick.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,5 @@ CherryPick.prototype.downloadAndPatch = LandingSession.prototype.downloadAndPatc
151151
CherryPick.prototype.validateLint = LandingSession.prototype.validateLint;
152152
CherryPick.prototype.getMessagePath = LandingSession.prototype.getMessagePath;
153153
CherryPick.prototype.saveMessage = LandingSession.prototype.saveMessage;
154+
CherryPick.prototype.generateAmendedMessage =
155+
LandingSession.prototype.generateAmendedMessage;

‎test/unit/cherry_pick.test.js‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { describe, it } from 'node:test';
2+
import assert from 'node:assert';
3+
4+
import CherryPick from '../../lib/cherry_pick.js';
5+
6+
function stubCli() {
7+
return {
8+
warn() {},
9+
ok() {},
10+
log() {},
11+
async prompt() { return 'CVE-2026-XXXXX'; }
12+
};
13+
}
14+
15+
describe('CherryPick: prototype wiring', () => {
16+
// `amend()` is borrowed from LandingSession and calls
17+
// `this.generateAmendedMessage()`, so it must be borrowed too.
18+
for (const method of [
19+
'downloadAndPatch',
20+
'validateLint',
21+
'getMessagePath',
22+
'saveMessage',
23+
'generateAmendedMessage'
24+
]) {
25+
it(`borrows ${method} from LandingSession`, () => {
26+
assert.strictEqual(typeof CherryPick.prototype[method], 'function');
27+
});
28+
}
29+
});
30+
31+
describe('CherryPick: generateAmendedMessage', () => {
32+
it('adds the CVE-ID trailer from cveIds during a security cherry-pick', async() => {
33+
const cp = new CherryPick(896, process.cwd(), stubCli(), {
34+
owner: 'nodejs-private',
35+
repo: 'node-private',
36+
includeCVE: true,
37+
cveIds: ['CVE-2026-58044']
38+
});
39+
cp.metadata = 'PR-URL: https://github.com/nodejs-private/node-private/pull/896\n' +
40+
'Reviewed-By: Robert Nagy <[email protected]>';
41+
42+
const original = 'sqlite: invalidate tag store iterators on statement reset\n\n' +
43+
'PR-URL: https://github.com/nodejs/node/pull/123';
44+
45+
const amended = await cp.generateAmendedMessage(original);
46+
assert.match(amended, /CVE-ID: CVE-2026-58044/);
47+
});
48+
});

0 commit comments

Comments
 (0)