Skip to content
Snippets Groups Projects
Commit 910793e5 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix: check onboarding pr when handling config error

Instead of checking for config.repoIsOnboarded, just check for the onboarding PR and reverse the logic.

Closes #1339
parent 1c58bd98
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,13 @@ async function raiseConfigWarningIssue(config, error) {
if (error.validationMessage) {
body += `Message: ${error.validationMessage}\n`;
}
if (config.repoIsOnboarded) {
const pr = await platform.getBranchPr('renovate/configure');
if (pr && pr.state && pr.state.startsWith('open')) {
logger.info('Updating onboarding PR with config error notice');
body = `## Action Required: Fix Renovate Configuration\n\n${body}`;
body += `\n\nOnce you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration.`;
await platform.updatePr(pr.number, 'Configure Renovate', body);
} else {
const res = await platform.ensureIssue(
'Action Required: Fix Renovate Configuration',
body
......@@ -20,12 +26,5 @@ async function raiseConfigWarningIssue(config, error) {
if (res) {
logger.warn({ configError: error, res }, 'Config Warning');
}
} else {
// update onboarding Pr
logger.info('Updating onboarding PR');
const pr = await platform.getBranchPr('renovate/configure');
body = `## Action Required: Fix Renovate Configuration\n\n${body}`;
body += `\n\nOnce you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration.`;
await platform.updatePr(pr.number, 'Configure Renovate', body);
}
}
......@@ -14,7 +14,6 @@ describe('workers/repository/error-config', () => {
const error = new Error('config-validation');
error.configFile = 'package.json';
error.validationMessage = 'some-message';
config.repoIsOnboarded = true;
platform.ensureIssue.mockReturnValue('created');
const res = await raiseConfigWarningIssue(config, error);
expect(res).toBeUndefined();
......@@ -23,8 +22,7 @@ describe('workers/repository/error-config', () => {
const error = new Error('config-validation');
error.configFile = 'package.json';
error.validationMessage = 'some-message';
config.repoIsOnboarded = false;
platform.getBranchPr.mockReturnValueOnce({ number: 1 });
platform.getBranchPr.mockReturnValueOnce({ number: 1, state: 'open' });
const res = await raiseConfigWarningIssue(config, error);
expect(res).toBeUndefined();
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment