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 { getErrors, getWarnings } = require('./errors-warnings');
|
||||
const { getBaseBranchDesc } = require('./base-branch');
|
||||
|
@ -78,14 +79,32 @@ You can post questions in [our Config Help repository](https://github.com/renova
|
|||
logger.info('Creating onboarding PR');
|
||||
const labels = [];
|
||||
const useDefaultBranch = true;
|
||||
const pr = await platform.createPr(
|
||||
onboardingBranch,
|
||||
onboardingPrTitle,
|
||||
prBody,
|
||||
labels,
|
||||
useDefaultBranch
|
||||
);
|
||||
logger.info({ pr: pr.displayNumber }, 'Created onboarding PR');
|
||||
try {
|
||||
const pr = await platform.createPr(
|
||||
onboardingBranch,
|
||||
onboardingPrTitle,
|
||||
prBody,
|
||||
labels,
|
||||
useDefaultBranch
|
||||
);
|
||||
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 = {
|
||||
|
|
Loading…
Reference in a new issue