mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
refactor: pass branches explicitly to repo onboarding
This commit is contained in:
parent
7189f4682f
commit
4a4feb35ab
5 changed files with 18 additions and 14 deletions
|
@ -71,7 +71,7 @@ async function renovateRepository(repoConfig) {
|
||||||
});
|
});
|
||||||
res = config.repoIsOnboarded
|
res = config.repoIsOnboarded
|
||||||
? await writeUpdates(config)
|
? await writeUpdates(config)
|
||||||
: await ensureOnboardingPr(config);
|
: await ensureOnboardingPr(config, config.branches);
|
||||||
logger.setMeta({ repository: config.repository });
|
logger.setMeta({ repository: config.repository });
|
||||||
config.branchPrefix = commonConfig
|
config.branchPrefix = commonConfig
|
||||||
? commonConfig.branchPrefix
|
? commonConfig.branchPrefix
|
||||||
|
|
|
@ -3,8 +3,11 @@ const { getErrors, getWarnings } = require('./errors-warnings');
|
||||||
const { getBaseBranchDesc } = require('./base-branch');
|
const { getBaseBranchDesc } = require('./base-branch');
|
||||||
const { getPrList } = require('./pr-list');
|
const { getPrList } = require('./pr-list');
|
||||||
|
|
||||||
async function ensureOnboardingPr(config) {
|
async function ensureOnboardingPr(config, branches) {
|
||||||
logger.debug('ensureOnboardingPr()');
|
logger.debug('ensureOnboardingPr()');
|
||||||
|
if (config.repoIsOnboarded) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
logger.trace({ config });
|
logger.trace({ config });
|
||||||
const onboardingBranch = `renovate/configure`;
|
const onboardingBranch = `renovate/configure`;
|
||||||
const onboardingPrTitle = 'Configure Renovate';
|
const onboardingPrTitle = 'Configure Renovate';
|
||||||
|
@ -41,7 +44,7 @@ You can post questions in [our Config Help repository](https://github.com/renova
|
||||||
prBody = prBody.replace('{{WARNINGS}}\n', getWarnings(config));
|
prBody = prBody.replace('{{WARNINGS}}\n', getWarnings(config));
|
||||||
prBody = prBody.replace('{{ERRORS}}\n', getErrors(config));
|
prBody = prBody.replace('{{ERRORS}}\n', getErrors(config));
|
||||||
prBody = prBody.replace('{{BASEBRANCH}}\n', getBaseBranchDesc(config));
|
prBody = prBody.replace('{{BASEBRANCH}}\n', getBaseBranchDesc(config));
|
||||||
prBody = prBody.replace('{{PRLIST}}\n', getPrList(config));
|
prBody = prBody.replace('{{PRLIST}}\n', getPrList(config, branches));
|
||||||
// istanbul ignore if
|
// istanbul ignore if
|
||||||
if (config.global) {
|
if (config.global) {
|
||||||
if (config.global.prBanner) {
|
if (config.global.prBanner) {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
function getPrList(config) {
|
function getPrList(config, branches) {
|
||||||
const { branches } = config;
|
|
||||||
logger.debug('getPrList()');
|
logger.debug('getPrList()');
|
||||||
logger.trace({ config });
|
logger.trace({ config });
|
||||||
let prDesc = `\n### What to Expect\n\n`;
|
let prDesc = `\n### What to Expect\n\n`;
|
||||||
|
|
|
@ -11,18 +11,20 @@ describe('workers/repository/onboarding/pr', () => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
config = {
|
config = {
|
||||||
...defaultConfig,
|
...defaultConfig,
|
||||||
|
|
||||||
errors: [],
|
errors: [],
|
||||||
warnings: [],
|
warnings: [],
|
||||||
description: [],
|
description: [],
|
||||||
branches: [],
|
|
||||||
packageFiles: [{ packageFile: 'package.json' }],
|
packageFiles: [{ packageFile: 'package.json' }],
|
||||||
};
|
};
|
||||||
platform.createPr.mockReturnValue({});
|
platform.createPr.mockReturnValue({});
|
||||||
});
|
});
|
||||||
let createPrBody;
|
let createPrBody;
|
||||||
|
it('returns if onboarded', async () => {
|
||||||
|
config.repoIsOnboarded = true;
|
||||||
|
expect(await ensureOnboardingPr(config, [])).toBe(null);
|
||||||
|
});
|
||||||
it('creates PR', async () => {
|
it('creates PR', async () => {
|
||||||
await ensureOnboardingPr(config);
|
await ensureOnboardingPr(config, []);
|
||||||
expect(platform.createPr.mock.calls).toHaveLength(1);
|
expect(platform.createPr.mock.calls).toHaveLength(1);
|
||||||
createPrBody = platform.createPr.mock.calls[0][2];
|
createPrBody = platform.createPr.mock.calls[0][2];
|
||||||
});
|
});
|
||||||
|
@ -31,7 +33,7 @@ describe('workers/repository/onboarding/pr', () => {
|
||||||
title: 'Configure Renovate',
|
title: 'Configure Renovate',
|
||||||
body: createPrBody,
|
body: createPrBody,
|
||||||
});
|
});
|
||||||
await ensureOnboardingPr(config);
|
await ensureOnboardingPr(config, []);
|
||||||
expect(platform.createPr.mock.calls).toHaveLength(0);
|
expect(platform.createPr.mock.calls).toHaveLength(0);
|
||||||
expect(platform.updatePr.mock.calls).toHaveLength(0);
|
expect(platform.updatePr.mock.calls).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
@ -41,7 +43,7 @@ describe('workers/repository/onboarding/pr', () => {
|
||||||
title: 'Configure Renovate',
|
title: 'Configure Renovate',
|
||||||
body: createPrBody,
|
body: createPrBody,
|
||||||
});
|
});
|
||||||
await ensureOnboardingPr(config);
|
await ensureOnboardingPr(config, []);
|
||||||
expect(platform.createPr.mock.calls).toHaveLength(0);
|
expect(platform.createPr.mock.calls).toHaveLength(0);
|
||||||
expect(platform.updatePr.mock.calls).toHaveLength(1);
|
expect(platform.updatePr.mock.calls).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('workers/repository/onboarding/pr/pr-list', () => {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
it('has special lock file maintenance description', () => {
|
it('has special lock file maintenance description', () => {
|
||||||
config.branches = [
|
const branches = [
|
||||||
{
|
{
|
||||||
prTitle: 'Lock file maintenance',
|
prTitle: 'Lock file maintenance',
|
||||||
schedule: ['before 5am'],
|
schedule: ['before 5am'],
|
||||||
|
@ -26,11 +26,11 @@ describe('workers/repository/onboarding/pr/pr-list', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const res = getPrList(config);
|
const res = getPrList(config, branches);
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
it('handles multiple', () => {
|
it('handles multiple', () => {
|
||||||
config.branches = [
|
const branches = [
|
||||||
{
|
{
|
||||||
prTitle: 'Pin dependencies',
|
prTitle: 'Pin dependencies',
|
||||||
branchName: 'renovate/pin-dependencies',
|
branchName: 'renovate/pin-dependencies',
|
||||||
|
@ -63,7 +63,7 @@ describe('workers/repository/onboarding/pr/pr-list', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const res = getPrList(config);
|
const res = getPrList(config, branches);
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue