Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always show dependency dashboard footer #7078

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`workers/repository/master-issue ensureMasterIssue() open or update Dependency Dashboard when all branches are closed and dependencyDashboardAutoclose is false 1`] = `
"This issue contains a list of Renovate updates and their statuses.

This repository currently has no open or pending branches.

---
And this is a footer
"
`;
5 changes: 2 additions & 3 deletions lib/workers/repository/dependency-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,14 @@ describe('workers/repository/master-issue', () => {
it('open or update Dependency Dashboard when all branches are closed and dependencyDashboardAutoclose is false', async () => {
const branches: BranchConfig[] = [];
config.dependencyDashboard = true;
config.dependencyDashboardFooter = 'And this is a footer';
await dependencyDashboard.ensureMasterIssue(config, branches);
expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(0);
expect(platform.ensureIssue).toHaveBeenCalledTimes(1);
expect(platform.ensureIssue.mock.calls[0][0].title).toBe(
config.dependencyDashboardTitle
);
expect(platform.ensureIssue.mock.calls[0][0].body).toBe(
'This repository is up-to-date and has no outstanding updates open or pending.'
);
expect(platform.ensureIssue.mock.calls[0][0].body).toMatchSnapshot();
expect(platform.getBranchPr).toHaveBeenCalledTimes(0);
expect(platform.findPr).toHaveBeenCalledTimes(0);

Expand Down
38 changes: 14 additions & 24 deletions lib/workers/repository/dependency-dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import is from '@sindresorhus/is';
import { RenovateConfig } from '../../config';
import { logger } from '../../logger';
import { Pr, platform } from '../../platform';
Expand Down Expand Up @@ -40,34 +41,18 @@ export async function ensureMasterIssue(
return;
}
logger.debug('Ensuring Dependency Dashboard');
if (
!branches.length ||
branches.every((branch) => branch.res === 'automerged')
) {
if (config.dependencyDashboardAutoclose) {
logger.debug('Closing Dependency Dashboard');
if (config.dryRun) {
logger.info(
'DRY-RUN: Would close Dependency Dashboard ' +
config.dependencyDashboardTitle
);
} else {
await platform.ensureIssueClosing(config.dependencyDashboardTitle);
}
return;
}
const hasBranches =
is.nonEmptyArray(branches) &&
branches.some((branch) => branch.res !== 'automerged');
if (config.dependencyDashboardAutoclose && !hasBranches) {
if (config.dryRun) {
logger.info(
'DRY-RUN: Would ensure Dependency Dashboard ' +
'DRY-RUN: Would close Dependency Dashboard ' +
config.dependencyDashboardTitle
);
} else {
await platform.ensureIssue({
title: config.dependencyDashboardTitle,
reuseTitle,
body:
'This repository is up-to-date and has no outstanding updates open or pending.',
});
logger.debug('Closing Dependency Dashboard');
await platform.ensureIssueClosing(config.dependencyDashboardTitle);
}
return;
}
Expand Down Expand Up @@ -204,8 +189,13 @@ export async function ensureMasterIssue(
issueBody += '\n';
}

// istanbul ignore if
if (!hasBranches) {
issueBody +=
'This repository currently has no open or pending branches.\n\n';
}

if (config.dependencyDashboardFooter?.length) {
// istanbul ignore if
rarkins marked this conversation as resolved.
Show resolved Hide resolved
issueBody += `---\n${config.dependencyDashboardFooter}\n`;
}

Expand Down