FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: borrow generateAmendedMessage in CherryPick by RafaelGSS · Pull Request #1125 · nodejs/node-core-utils · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions lib/cherry_pick.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,5 @@ CherryPick.prototype.downloadAndPatch = LandingSession.prototype.downloadAndPatc
CherryPick.prototype.validateLint = LandingSession.prototype.validateLint;
CherryPick.prototype.getMessagePath = LandingSession.prototype.getMessagePath;
CherryPick.prototype.saveMessage = LandingSession.prototype.saveMessage;
CherryPick.prototype.generateAmendedMessage =
LandingSession.prototype.generateAmendedMessage;
48 changes: 48 additions & 0 deletions test/unit/cherry_pick.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { describe, it } from 'node:test';
import assert from 'node:assert';

import CherryPick from '../../lib/cherry_pick.js';

function stubCli() {
return {
warn() {},
ok() {},
log() {},
async prompt() { return 'CVE-2026-XXXXX'; }
};
}

describe('CherryPick: prototype wiring', () => {
// `amend()` is borrowed from LandingSession and calls
// `this.generateAmendedMessage()`, so it must be borrowed too.
for (const method of [
'downloadAndPatch',
'validateLint',
'getMessagePath',
'saveMessage',
'generateAmendedMessage'
]) {
it(`borrows ${method} from LandingSession`, () => {
assert.strictEqual(typeof CherryPick.prototype[method], 'function');
});
}
});

describe('CherryPick: generateAmendedMessage', () => {
it('adds the CVE-ID trailer from cveIds during a security cherry-pick', async() => {
const cp = new CherryPick(896, process.cwd(), stubCli(), {
owner: 'nodejs-private',
repo: 'node-private',
includeCVE: true,
cveIds: ['CVE-2026-58044']
});
cp.metadata = 'PR-URL: https://github.com/nodejs-private/node-private/pull/896\n' +
'Reviewed-By: Robert Nagy <ronagy@icloud.com>';

const original = 'sqlite: invalidate tag store iterators on statement reset\n\n' +
'PR-URL: https://github.com/nodejs/node/pull/123';

const amended = await cp.generateAmendedMessage(original);
assert.match(amended, /CVE-ID: CVE-2026-58044/);
});
});
Loading

Back | FazBrowse Home | New Git URL