Skip to content

Commit

Permalink
Fix library parser to trim trailing LF (#380)
Browse files Browse the repository at this point in the history
* Fix test fixture for update requirement pattern

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

* `npm run build`
  • Loading branch information
kachick authored May 24, 2023
1 parent 0908fa1 commit 64bd9b8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dependabot/update_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
Expand Down
1 change: 1 addition & 0 deletions src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand Down

0 comments on commit 64bd9b8

Please sign in to comment.