From 17ce224ec306571f53a062def8361dfbbd5e9fa3 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Tue, 12 Nov 2024 18:46:16 -0300 Subject: [PATCH] test: add cveId tests --- .github/workflows/test-and-release.yml | 2 +- commit-to-output.js | 10 +++------- test.js | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index c98543d..881da41 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: Use Node.js ${{ matrix.node }} uses: actions/setup-node@v4.0.2 with: diff --git a/commit-to-output.js b/commit-to-output.js index f11ab1a..dfc5f74 100644 --- a/commit-to-output.js +++ b/commit-to-output.js @@ -39,9 +39,9 @@ export const formatType = { function toStringPlaintext (data) { let s = '' + if (data.cveId) { - const pr = data.pr ? data.prUrl : '' - return ` * ${data.cveId} - ${data.summary.trim()} - ${pr}` + s += `(${data.cveId})` } s += (data.semver || []).length ? `(${data.semver.join(', ').toUpperCase()}) ` : '' @@ -98,11 +98,7 @@ function toStringMarkdown (data) { } function toStringMessageOnly (data) { - let cveData - if (data.cveId) { - cveData = `${data.cveId} - ` - } - return ` * ${cveData}${data.summary.trim()}` + return ` * ${data.cveId ? '(' + data.cveId + ') ' : ''}${data.summary.trim()}` } export function commitToOutput (commit, format, ghId, commitUrl) { diff --git a/test.js b/test.js index 27fe14e..40ee305 100644 --- a/test.js +++ b/test.js @@ -142,3 +142,12 @@ test('test find-matching-prs', (t) => { `) t.end() }) + +test('test group, CVE-ID', (t) => { + const out = exec('--md --start-ref=43d428b3d2 --end-ref=43d428b3d2 --group --filter-release') + t.equal( + out, + `* \\[[\`43d428b3d2\`](https://github.com/nodejs/changelog-maker/commit/43d428b3d2)] - **(CVE-2024-22020)** **feat**: add cveId support to commmit output (RafaelGSS) [nodejs/node#55819](https://github.com/nodejs/node/pull/55819) +`) + t.end() +})