|
5 | 5 | // |
6 | 6 | // Example: |
7 | 7 | // $ git log upstream/vXX.x...upstream/vX.X.X-proposal \ |
8 | | -// --format='{"prURL":"%(trailers:key=PR-URL,valueonly,separator=)","title":"%s","smallSha":"%h"}' \ |
| 8 | +// --reverse --format='{"prURL":"%(trailers:key=PR-URL,valueonly,separator=)","title":"%s","smallSha":"%h"}' \ |
| 9 | +// | sed 's/,"title":"Revert "\([^"]\+\)""/,"title":"Revert \\"\1\\""/g' \ |
9 | 10 | // | ./lint-release-proposal-commit-list.mjs "path/to/CHANGELOG.md" "$(git rev-parse upstream/vX.X.X-proposal)" |
10 | 11 |
|
11 | 12 | const[,,CHANGELOG_PATH,RELEASE_COMMIT_SHA]=process.argv; |
@@ -52,20 +53,33 @@ for await (const line of stdinLineByLine) { |
52 | 53 | assert.notStrictEqual(lineStart,-1,`Cannot find ${smallSha} on the list`); |
53 | 54 | constlineEnd=commitList.indexOf('\n',lineStart+1); |
54 | 55 |
|
55 | | -constcolonIndex=title.indexOf(':'); |
56 | | -constexpectedCommitTitle=`${`**${title.slice(0,colonIndex)}`.replace('**Revert "','_**Revert**_ "**')}**${title.slice(colonIndex)}`; |
57 | 56 | try{ |
58 | | -assert(commitList.lastIndexOf(`/${smallSha})] - ${expectedCommitTitle} (`,lineEnd)>lineStart,`Commit title doesn't match`); |
| 57 | +constcolonIndex=title.indexOf(':'); |
| 58 | +constexpectedCommitTitle=`${`**${title.slice(0,colonIndex)}`.replace('**Revert "','_**Revert**_ "**')}**${title.slice(colonIndex)}`; |
| 59 | +try{ |
| 60 | +assert(commitList.lastIndexOf(`/${smallSha})] - ${expectedCommitTitle} (`,lineEnd)>lineStart,`Changelog entry doesn't match for ${smallSha}`); |
| 61 | +}catch(e){ |
| 62 | +if(e?.code==='ERR_ASSERTION'){ |
| 63 | +e.operator='includes'; |
| 64 | +e.expected=expectedCommitTitle; |
| 65 | +e.actual=commitList.slice(lineStart+1,lineEnd); |
| 66 | +} |
| 67 | +throwe; |
| 68 | +} |
| 69 | +assert.strictEqual(commitList.slice(lineEnd-prURL.length-2,lineEnd),`(${prURL})`,`when checking ${smallSha}${title}`); |
| 70 | + |
59 | 71 | }catch(e){ |
60 | | -if(e?.code==='ERR_ASSERTION'){ |
61 | | -e.operator='includes'; |
62 | | -e.expected=expectedCommitTitle; |
63 | | -e.actual=commitList.slice(lineStart+1,lineEnd); |
| 72 | +if(e?.code!=='ERR_ASSERTION'){ |
| 73 | +throwe; |
64 | 74 | } |
65 | | -throwe; |
| 75 | +letline=1; |
| 76 | +for(leti=0;i<lineStart+commitListingStart;i=changelog.indexOf('\n',i+1)){ |
| 77 | +line++; |
| 78 | +} |
| 79 | +console.error(`::error file=${CHANGELOG_PATH},line=${line},title=Release proposal linter::${e.message}`); |
| 80 | +console.error(e); |
| 81 | +process.exitCode||=1; |
66 | 82 | } |
67 | | -assert.strictEqual(commitList.slice(lineEnd-prURL.length-2,lineEnd),`(${prURL})`,`when checking ${smallSha}${title}`); |
68 | | - |
69 | 83 | expectedNumberOfCommitsLeft--; |
70 | 84 | console.log(prURL); |
71 | 85 | } |
|
0 commit comments