Skip to content

Commit

Permalink
Fix regex (#303)
Browse files Browse the repository at this point in the history
* Cut v3.11.0 (#302)

* Look for html vs markdown to denote a list

* better comment
  • Loading branch information
dangoslen authored Dec 21, 2024
1 parent f37611f commit cb4aaf9
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [UNRELEASED]

## [3.11.1]

### Fixed
- Corrects the regex introduced in [3.11.0](#3110) to correct reading too many entries

## [3.11.0]

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions __tests__/entry-extractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ const PULL_REQUEST_WITH_COMMITS_IN_BODY = {
Changelog
Commits
* Updates \`dep\` from a to b
<li>Updates \`dep\` from a to b</li>
<li>Bumps \`dep\` from a to b</li>
`
}
}
Expand Down Expand Up @@ -232,7 +233,7 @@ describe('the dependabot extractor', () => {
expect(entry.newVersion).toStrictEqual('3.12.3')
})

test('extracts multiple entries from body', async () => {
test('extracts multiple entries from body, skipping commits in a list', async () => {
const entries = extractor.getEntries(PULL_REQUEST_WITH_COMMITS_IN_BODY)

expect(entries).toHaveLength(1)
Expand Down
2 changes: 1 addition & 1 deletion coverage/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions 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 dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dependabot-changelog-helper",
"version": "3.11.0",
"version": "3.11.1",
"private": false,
"description": "A GitHub Action to auto-add dependabot changes to your changelog and increment version numbers",
"main": "lib/dependabot-helper.js",
Expand Down
5 changes: 3 additions & 2 deletions src/entries/dependabot-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ export class DependabotExtractor implements EntryExtractor {

constructor() {
/** Regex explanation
* --- Start of the line must not be a '*' character which is used for markdown to denote a list
* --- Start of the line must not be a '<li>' HTML tag which is used to denote a list within the <summary> tag
* --- Matches [Bump, bump, Bumps, bumps, Update, update, Updates or update], without capturing it
* | --- Matches any non-whitespace character; matching as a few as possible
* | | --- Matches any non-whitespace character as the package name
* | | | --- Matches any non-whitespace character as the version numbers
* | | | | |
*/
this.regex = new RegExp(
/^[^*]*(?:(?:U|u)pdate|(?:B|b)ump)s? (\S+?) (?:requirement )?from (\S*) to (\S*)/
// eslint-disable-next-line no-useless-escape
/^(?!<li\>).*(?:(?:U|u)pdate|(?:B|b)ump)s? (\S+?) (?:requirement )?from (\S*) to (\S*)/
)
}

Expand Down

0 comments on commit cb4aaf9

Please sign in to comment.