Select Git revision
dependency-dashboard.ts
dependency-dashboard.ts 8.26 KiB
import is from '@sindresorhus/is';
import { nameFromLevel } from 'bunyan';
import { getAdminConfig } from '../../config/admin';
import type { RenovateConfig } from '../../config/types';
import { getProblems, logger } from '../../logger';
import { Pr, platform } from '../../platform';
import { PrState } from '../../types';
import { BranchConfig, BranchResult } from '../types';
function getListItem(branch: BranchConfig, type: string, pr?: Pr): string {
let item = ' - [ ] ';
item += `<!-- ${type}-branch=${branch.branchName} -->`;
if (pr) {
item += `[${branch.prTitle}](../pull/${pr.number})`;
} else {
item += branch.prTitle;
}
const uniquePackages = [
...new Set(branch.upgrades.map((upgrade) => '`' + upgrade.depName + '`')),
];
if (uniquePackages.length < 2) {
return item + '\n';
}
return item + ' (' + uniquePackages.join(', ') + ')\n';
}
function appendRepoProblems(config: RenovateConfig, issueBody: string): string {
let newIssueBody = issueBody;
const repoProblems = new Set(
getProblems()
.filter(
(problem) =>
problem.repository === config.repository && !problem.artifactErrors
)
.map(
(problem) =>
`${nameFromLevel[problem.level].toUpperCase()}: ${problem.msg}`
)
);
if (repoProblems.size) {
newIssueBody += '## Repository problems\n\n';
newIssueBody +=
'These problems occurred while renovating this repository.\n\n';
for (const repoProblem of repoProblems) {
newIssueBody += ` - ${repoProblem}\n`;
}
newIssueBody += '\n';
}
return newIssueBody;
}
export async function ensureMasterIssue(
config: RenovateConfig,
branches: BranchConfig[]
): Promise<void> {
// legacy/migrated issue
const reuseTitle = 'Update Dependencies (Renovate Bot)';
if (
!(
config.dependencyDashboard ||
config.dependencyDashboardApproval ||
config.packageRules?.some((rule) => rule.dependencyDashboardApproval) ||
branches.some(
(branch) =>
branch.dependencyDashboardApproval ||
branch.dependencyDashboardPrApproval
)
)
) {
return;