From 64bd9b825fbf47db8a7e97450b5708ed935ea4c7 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Wed, 24 May 2023 10:12:53 +0900 Subject: [PATCH] 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` --- dist/index.js | 2 +- src/dependabot/update_metadata.ts | 2 +- src/main.test.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index f2fa1677..4b204538 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 (?v?\d[^ ]*) to (?v?\d[^ ]*)\.$/m); - const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?v?\d[^ ]*) to \S*? ?(?v?\d[^ ]*)$/m); + const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?v?\d\S*) to \S*? ?(?v?\d\S*)$/m); const yamlFragment = commitMessage.match(/^-{3}\n(?[\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 })); diff --git a/src/dependabot/update_metadata.ts b/src/dependabot/update_metadata.ts index f1f1f1c3..244f2ac6 100644 --- a/src/dependabot/update_metadata.ts +++ b/src/dependabot/update_metadata.ts @@ -29,7 +29,7 @@ export interface scoreLookup { export async function parse (commitMessage: string, body: string, branchName: string, mainBranch: string, lookup?: alertLookup, getScore?: scoreLookup): Promise> { const bumpFragment = commitMessage.match(/^Bumps .* from (?v?\d[^ ]*) to (?v?\d[^ ]*)\.$/m) - const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?v?\d[^ ]*) to \S*? ?(?v?\d[^ ]*)$/m) + const updateFragment = commitMessage.match(/^Update .* requirement from \S*? ?(?v?\d\S*) to \S*? ?(?v?\d\S*)$/m) const yamlFragment = commitMessage.match(/^-{3}\n(?[\S|\s]*?)\n^\.{3}\n/m) const newMaintainer = !!body.match(/Maintainer changes/m) const lookupFn = lookup ?? (() => Promise.resolve({ alertState: '', ghsaId: '', cvss: 0 })) diff --git a/src/main.test.ts b/src/main.test.ts index 33420a67..f0fbeda1 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -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' +