Extract updated packages from pull request body
Fixes getting package list when PR updates multiple packages (monorepos)
This commit is contained in:
parent
ee4de6a871
commit
e3e0495a9f
@ -414,6 +414,7 @@ class RepositoryFetcher {
|
|||||||
PR${number}: pullRequest(number: ${number}) {
|
PR${number}: pullRequest(number: ${number}) {
|
||||||
__typename
|
__typename
|
||||||
title
|
title
|
||||||
|
body
|
||||||
url
|
url
|
||||||
author {
|
author {
|
||||||
__typename
|
__typename
|
||||||
@ -643,8 +644,43 @@ function isFeature({labels}) {
|
|||||||
// chore(deps): update dependency mini-css-extract-plugin to v0.4.3
|
// chore(deps): update dependency mini-css-extract-plugin to v0.4.3
|
||||||
// fix(deps): update dependency web-push to v3.3.3
|
// fix(deps): update dependency web-push to v3.3.3
|
||||||
// chore(deps): update babel monorepo to v7.1.0
|
// chore(deps): update babel monorepo to v7.1.0
|
||||||
function extractPackages({title, url}) {
|
function extractPackages({title, body, url}) {
|
||||||
const extracted = /(?:U|u)pdate(?: dependency)? ([\w-,` ./@]+?) (?:monorepo )?to /.exec(title);
|
// Extract updated packages from renovate-bot's pull request body
|
||||||
|
let list = /^This PR contains the following updates:\n\n(?:[\s\S]+?)---\|$\n([\s\S]+?)\n\n---/m.exec(
|
||||||
|
body
|
||||||
|
);
|
||||||
|
|
||||||
|
if (list) {
|
||||||
|
const packages = [];
|
||||||
|
list = list[1].split("\n");
|
||||||
|
|
||||||
|
for (let line of list) {
|
||||||
|
line = line
|
||||||
|
.split("|")[1] // Split the table and take the first column
|
||||||
|
.trim()
|
||||||
|
.split(" ")[0]; // Remove any spaces and take the first word (skip source link, etc)
|
||||||
|
|
||||||
|
const pkgName = /([\w-, ./@]+)/.exec(line);
|
||||||
|
|
||||||
|
if (!pkgName) {
|
||||||
|
log.warn(`Failed to extract package name from: ${url}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
packages.push(pkgName[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packages.length > 0) {
|
||||||
|
return packages;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.warn(`Failed to extract package from: ${url}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to extracting package from title
|
||||||
|
const extracted = /(?:U|u)pdate(?: dependency)? ([\w-,` ./@]+?) (?:packages |monorepo )?to /.exec(
|
||||||
|
title
|
||||||
|
);
|
||||||
|
|
||||||
if (!extracted) {
|
if (!extracted) {
|
||||||
log.warn(`Failed to extract package from: ${title} ${colors.gray(url)}`);
|
log.warn(`Failed to extract package from: ${title} ${colors.gray(url)}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user