Skip to content

Commit

Permalink
fix: correct baseBranches description in onboarding PR
Browse files Browse the repository at this point in the history
Closes #6527
  • Loading branch information
rarkins committed Jun 17, 2020
1 parent 0345b40 commit 4b2f523
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Expand Up @@ -5,3 +5,5 @@ exports[`workers/repository/onboarding/pr/base-branch getBaseBranchDesc() descri
"
`;

exports[`workers/repository/onboarding/pr/base-branch getBaseBranchDesc() describes baseBranches 1`] = `"You have configured Renovate to use the following baseBranches: \`some-branch\`, \`some-other-branch\`."`;
7 changes: 6 additions & 1 deletion lib/workers/repository/onboarding/pr/base-branch.spec.ts
Expand Up @@ -14,7 +14,12 @@ describe('workers/repository/onboarding/pr/base-branch', () => {
expect(res).toEqual('');
});
it('describes baseBranch', () => {
config.baseBranch = 'some-branch';
config.baseBranches = ['some-branch'];
const res = getBaseBranchDesc(config);
expect(res).toMatchSnapshot();
});
it('describes baseBranches', () => {
config.baseBranches = ['some-branch', 'some-other-branch'];
const res = getBaseBranchDesc(config);
expect(res).toMatchSnapshot();
});
Expand Down
12 changes: 9 additions & 3 deletions lib/workers/repository/onboarding/pr/base-branch.ts
Expand Up @@ -2,7 +2,13 @@ import { RenovateConfig } from '../../../../config';

export function getBaseBranchDesc(config: RenovateConfig): string {
// Describe base branch only if it's configured
return config.baseBranch
? `You have configured Renovate to use branch \`${config.baseBranch}\` as base branch.\n\n`
: '';
if (!config.baseBranches?.length) {
return '';
}
if (config.baseBranches.length > 1) {
return `You have configured Renovate to use the following baseBranches: ${config.baseBranches
.map((branch) => `\`${branch}\``)
.join(', ')}.`;
}
return `You have configured Renovate to use branch \`${config.baseBranches[0]}\` as base branch.\n\n`;
}

0 comments on commit 4b2f523

Please sign in to comment.