mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(onboarding): delete onboarding PR branch if pr not found
This commit is contained in:
parent
bb28ae27a2
commit
efa5edbdf3
1 changed files with 27 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
const is = require('@sindresorhus/is');
|
||||||
const { getConfigDesc } = require('./config-description');
|
const { getConfigDesc } = require('./config-description');
|
||||||
const { getErrors, getWarnings } = require('./errors-warnings');
|
const { getErrors, getWarnings } = require('./errors-warnings');
|
||||||
const { getBaseBranchDesc } = require('./base-branch');
|
const { getBaseBranchDesc } = require('./base-branch');
|
||||||
|
@ -78,6 +79,7 @@ You can post questions in [our Config Help repository](https://github.com/renova
|
||||||
logger.info('Creating onboarding PR');
|
logger.info('Creating onboarding PR');
|
||||||
const labels = [];
|
const labels = [];
|
||||||
const useDefaultBranch = true;
|
const useDefaultBranch = true;
|
||||||
|
try {
|
||||||
const pr = await platform.createPr(
|
const pr = await platform.createPr(
|
||||||
onboardingBranch,
|
onboardingBranch,
|
||||||
onboardingPrTitle,
|
onboardingPrTitle,
|
||||||
|
@ -86,6 +88,23 @@ You can post questions in [our Config Help repository](https://github.com/renova
|
||||||
useDefaultBranch
|
useDefaultBranch
|
||||||
);
|
);
|
||||||
logger.info({ pr: pr.displayNumber }, 'Created onboarding PR');
|
logger.info({ pr: pr.displayNumber }, 'Created onboarding PR');
|
||||||
|
} catch (err) /* istanbul ignore next */ {
|
||||||
|
if (
|
||||||
|
err.statusCode === 422 &&
|
||||||
|
err.response &&
|
||||||
|
err.response.body &&
|
||||||
|
!is.empty(err.response.body.errors) &&
|
||||||
|
err.response.body.errors[0].message &&
|
||||||
|
err.response.body.errors[0].message.startsWith(
|
||||||
|
'A pull request already exists'
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
logger.info('Onboarding PR already exists but cannot find it');
|
||||||
|
await platform.deleteBranch(onboardingBranch);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in a new issue