2018-10-04 08:07:59 +00:00
|
|
|
module.exports = {
|
|
|
|
ensureMasterIssue,
|
|
|
|
};
|
|
|
|
|
|
|
|
// istanbul ignore next
|
|
|
|
function getListItem(branch, type) {
|
|
|
|
let item = ' - [ ] ';
|
|
|
|
item += `<!-- ${type}-branch=${branch.branchName} -->`;
|
|
|
|
if (branch.prNo) {
|
|
|
|
item += `[${branch.prTitle}](../pull/${branch.prNo})`;
|
|
|
|
} else {
|
|
|
|
item += branch.prTitle;
|
|
|
|
}
|
2018-10-04 08:38:16 +00:00
|
|
|
const uniquePackages = [
|
|
|
|
...new Set(branch.upgrades.map(upgrade => '`' + upgrade.depName + '`')),
|
|
|
|
];
|
|
|
|
if (uniquePackages.length < 2) {
|
2018-10-04 08:07:59 +00:00
|
|
|
return item + '\n';
|
|
|
|
}
|
2018-10-04 08:38:16 +00:00
|
|
|
return item + ' (' + uniquePackages.join(', ') + ')\n';
|
2018-10-04 08:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// istanbul ignore next
|
|
|
|
async function ensureMasterIssue(config, branches) {
|
|
|
|
if (!(config.masterIssue || config.masterIssueApproval)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
!branches.length ||
|
|
|
|
branches.every(branch => branch.res === 'automerged')
|
|
|
|
) {
|
|
|
|
if (config.masterIssueAutoclose) {
|
|
|
|
await platform.ensureIssueClosing(config.masterIssueTitle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await platform.ensureIssue(
|
|
|
|
config.masterIssueTitle,
|
|
|
|
'This repository is up-to-date and has no outstanding updates open or pending.'
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let issueBody =
|
|
|
|
'This issue contains a list of Renovate updates and their statuses.\n\n';
|
|
|
|
const pendingApprovals = branches.filter(
|
|
|
|
branch => branch.res === 'needs-approval'
|
|
|
|
);
|
|
|
|
if (pendingApprovals.length) {
|
|
|
|
issueBody += '## Pending Approval\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These PRs will be created by Renovate only once you click their checkbox below.\n\n';
|
|
|
|
for (const branch of pendingApprovals) {
|
|
|
|
issueBody += getListItem(branch, 'approve');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
|
|
|
const awaitingSchedule = branches.filter(
|
|
|
|
branch => branch.res === 'not-scheduled'
|
|
|
|
);
|
|
|
|
if (awaitingSchedule.length) {
|
|
|
|
issueBody += '## Awaiting Schedule\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.\n';
|
|
|
|
for (const branch of awaitingSchedule) {
|
|
|
|
issueBody += getListItem(branch, 'unschedule');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
2018-10-08 10:53:49 +00:00
|
|
|
const rateLimited = branches.filter(
|
|
|
|
branch => branch.res && branch.res.endsWith('pr-hourly-limit-reached')
|
2018-10-04 08:07:59 +00:00
|
|
|
);
|
|
|
|
if (rateLimited.length) {
|
|
|
|
issueBody += '## Rate Limited\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates are currently rate limited. Click on a checkbox below to override.\n\n';
|
|
|
|
for (const branch of rateLimited) {
|
|
|
|
issueBody += getListItem(branch, 'unlimit');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
2018-10-08 10:53:49 +00:00
|
|
|
const errorList = branches.filter(
|
|
|
|
branch => branch.res && branch.res.endsWith('error')
|
|
|
|
);
|
2018-10-04 08:07:59 +00:00
|
|
|
if (errorList.length) {
|
|
|
|
issueBody += '## Errored\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates encountered an error and will be retried. Click a checkbox below to force a retry now.\n\n';
|
|
|
|
for (const branch of errorList) {
|
|
|
|
issueBody += getListItem(branch, 'retry');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
2018-10-04 11:54:28 +00:00
|
|
|
const prEdited = branches.filter(branch => branch.res === 'pr-edited');
|
|
|
|
if (prEdited.length) {
|
|
|
|
issueBody += '## Edited/Blocked\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, check the box below.\n\n';
|
|
|
|
for (const branch of prEdited) {
|
|
|
|
issueBody += getListItem(branch, 'reset');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
2018-10-04 08:07:59 +00:00
|
|
|
const otherRes = [
|
|
|
|
'needs-approval',
|
|
|
|
'not-scheduled',
|
|
|
|
'pr-hourly-limit-reached',
|
|
|
|
'already-existed',
|
|
|
|
'error',
|
|
|
|
'automerged',
|
2018-10-04 11:54:28 +00:00
|
|
|
'pr-edited',
|
2018-10-04 08:07:59 +00:00
|
|
|
];
|
|
|
|
const inProgress = branches.filter(branch => !otherRes.includes(branch.res));
|
|
|
|
if (inProgress.length) {
|
|
|
|
issueBody += '## Open\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates have all been created already. Click a checkbox below to force a retry/rebase of any.\n\n';
|
|
|
|
for (const branch of inProgress) {
|
|
|
|
const pr = await platform.getBranchPr(branch.branchName);
|
|
|
|
if (pr) {
|
|
|
|
branch.prNo = pr.number;
|
|
|
|
}
|
|
|
|
issueBody += getListItem(branch, 'rebase');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
2018-10-08 10:53:49 +00:00
|
|
|
const alreadyExisted = branches.filter(
|
|
|
|
branch => branch.res && branch.res.endsWith('already-existed')
|
2018-10-04 08:07:59 +00:00
|
|
|
);
|
|
|
|
if (alreadyExisted.length) {
|
|
|
|
issueBody += '## Closed/Ignored\n\n';
|
|
|
|
issueBody +=
|
|
|
|
'These updates were closed unmerged and will not be recreated unless you click a checkbox below.\n\n';
|
|
|
|
for (const branch of alreadyExisted) {
|
|
|
|
issueBody += getListItem(branch, 'recreate');
|
|
|
|
}
|
|
|
|
issueBody += '\n';
|
|
|
|
}
|
|
|
|
await platform.ensureIssue(config.masterIssueTitle, issueBody);
|
|
|
|
}
|