From 910793e5f2f4f9dd98f6140191c12db8e8dcaadf Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 8 Jan 2018 15:53:52 +0100 Subject: [PATCH] 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 --- lib/workers/repository/error-config.js | 15 +++++++-------- test/workers/repository/error-config.spec.js | 4 +--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/workers/repository/error-config.js b/lib/workers/repository/error-config.js index ca65c6477a..c203df361f 100644 --- a/lib/workers/repository/error-config.js +++ b/lib/workers/repository/error-config.js @@ -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); } } diff --git a/test/workers/repository/error-config.spec.js b/test/workers/repository/error-config.spec.js index b07b791d58..222d49626a 100644 --- a/test/workers/repository/error-config.spec.js +++ b/test/workers/repository/error-config.spec.js @@ -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(); }); -- GitLab