Skip to content

Commit dab069c

Browse files
authored
Merge pull request #712 from linear-b/fix-dependabot-parser-for-updates
Improve Dependabot version extraction to support "Updates" pattern
2 parents 6995edc + 1986499 commit dab069c

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

plugins/filters/extractDependabotVersionBump/index.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
/**
22
* @module extractDependabotVersionBump
3-
* @description Extract version bump information from Dependabot PRs description
3+
* @description Extract version bump information from Dependabot PRs description.
4+
* Handles both "Bumps" and "Updates" patterns.
45
* @param {string} description - the PR description
5-
* @returns {string[]} V1 (to) and V2 (from)
6+
* @returns {string[]} An array with [to, from] versions, or null if no version info found
67
* @example {{ pr.description | extractDependabotVersionBump | compareSemver }}
78
* @license MIT
89
**/
910

1011

1112
module.exports = (desc) => {
12-
if (desc && desc !== '""' && desc !== "''" ) {
13-
const matches = /Bumps.*from ([\d\.]+[A-Za-zαß]*) to ([\d\.]+[A-Za-zαß]*)/.exec(desc);
14-
if (matches && matches.length == 3) {
15-
var [_, from, to] = matches;
16-
// remove trailing dot on to
17-
if (to[to.length - 1] === ".") {
13+
if (desc && desc !== '""' && desc !== "''" ) {
14+
// Match both "Bumps" and "Updates" patterns with version numbers
15+
// The regex captures version numbers that follow "from" and "to" keywords
16+
const regex = /(Bumps|Updates).*?from ([\d\.]+[A-Za-zαß]*) to ([\d\.]+[A-Za-zαß]*)/;
17+
const matches = regex.exec(desc);
18+
if (matches && matches.length == 4) {
19+
var [_, action, from, to] = matches;
20+
// Remove trailing dot on the "to" version if present
21+
if (to && to.length > 0 && to[to.length - 1] === ".") {
1822
to = to.slice(0, -1);
1923
}
24+
// Return [to, from] format to be compatible with compareSemver
2025
return [to, from];
2126
}
2227
}

plugins/filters/extractDependabotVersionBump/test.js

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)