Fix library parser to trim trailing LF (#380)

* Fix test fixture for update requirement pattern

* Fix to parse update fragment with considering "\n"

* `npm run build`
This commit is contained in:
Kenichi Kamiya
2023-05-24 10:12:53 +09:00
committed by GitHub
parent 0908fa19ff
commit 64bd9b825f
3 changed files with 3 additions and 2 deletions

2
dist/index.js generated vendored
View File

@@ -10090,7 +10090,7 @@ function parse(commitMessage, body, branchName, mainBranch, lookup, getScore) {
var _a, _b, _c, _d, _e, _f, _g, _h;
return __awaiter(this, void 0, void 0, function* () {
const bumpFragment = commitMessage.match(/^Bumps .* from (?<from>v?\d[^ ]*) to (?<to>v?\d[^ ]*)\.$/m);
const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?<from>v?\d[^ ]*) to \S*? ?(?<to>v?\d[^ ]*)$/m);
const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?<from>v?\d\S*) to \S*? ?(?<to>v?\d\S*)$/m);
const yamlFragment = commitMessage.match(/^-{3}\n(?<dependencies>[\S|\s]*?)\n^\.{3}\n/m);
const newMaintainer = !!body.match(/Maintainer changes/m);
const lookupFn = lookup !== null && lookup !== void 0 ? lookup : (() => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }));

View File

@@ -29,7 +29,7 @@ export interface scoreLookup {
export async function parse (commitMessage: string, body: string, branchName: string, mainBranch: string, lookup?: alertLookup, getScore?: scoreLookup): Promise<Array<updatedDependency>> {
const bumpFragment = commitMessage.match(/^Bumps .* from (?<from>v?\d[^ ]*) to (?<to>v?\d[^ ]*)\.$/m)
const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?<from>v?\d[^ ]*) to \S*? ?(?<to>v?\d[^ ]*)$/m)
const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?<from>v?\d\S*) to \S*? ?(?<to>v?\d\S*)$/m)
const yamlFragment = commitMessage.match(/^-{3}\n(?<dependencies>[\S|\s]*?)\n^\.{3}\n/m)
const newMaintainer = !!body.match(/Maintainer changes/m)
const lookupFn = lookup ?? (() => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 }))

View File

@@ -208,6 +208,7 @@ test('it sets the updated dependency as an output for subsequent actions when th
test('it sets the updated dependency as an output for subsequent actions when given a commit message for library', async () => {
const mockCommitMessage =
'Update rubocop requirement from ~> 1.30.1 to ~> 1.31.0\n' +
'\n' +
'Updates the requirements on [rubocop](https://github.com/rubocop/rubocop) to permit the latest version.\n' +
'- [Release notes](https://github.com/rubocop/rubocop/releases)\n' +
'- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)\n' +