Skip to content

Commit

Permalink
fix: always show dependency dashboard footer
Browse files Browse the repository at this point in the history
Closes #7035
  • Loading branch information
rarkins committed Aug 24, 2020
1 parent 70f1ae8 commit 304a059
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
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
issueBody += `---\n${config.dependencyDashboardFooter}\n`;
}

Expand Down

0 comments on commit 304a059

Please sign in to comment.