Skip to content

Commit

Permalink
test: add cveId tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Nov 27, 2024
1 parent 43d428b commit f2f235b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
npm run test:ci
release:
name: Release
permissions:
contents: write
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
10 changes: 3 additions & 7 deletions commit-to-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}) ` : ''
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@octokit/graphql": "^7.0.1",
"async": "^3.2.4",
"chalk": "^5.3.0",
"commit-stream": "^2.1.0",
"commit-stream": "^2.2.0",
"debug": "^4.3.4",
"ghauth": "^6.0.0",
"ghissues": "^1.1.4",
Expand Down
9 changes: 9 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

0 comments on commit f2f235b

Please sign in to comment.