Skip to content

Commit

Permalink
fix(github): delete fork after patch failure
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jul 9, 2020
1 parent 8326cf9 commit ab98794
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/platform/github/index.ts
Expand Up @@ -380,15 +380,19 @@ export async function initRepo({
}
);
} catch (err) /* istanbul ignore next */ {
logger.debug(
'Error updating fork reference - will try deleting fork to try again next time'
);
try {
await githubApi.deleteJson(`repos/${config.repository}`);
logger.info('Fork deleted');
} catch (deleteErr) {
logger.warn({ err: deleteErr }, 'Could not delete fork');
}
if (err instanceof ExternalHostError) {
throw err;
}
if (
err.statusCode === 422 &&
err.message.startsWith('Object does not exist')
) {
throw new Error(REPOSITORY_CHANGED);
}
throw new ExternalHostError(err);
}
} else {
logger.debug({ repository_fork: config.repository }, 'Created fork');
Expand Down

0 comments on commit ab98794

Please sign in to comment.