mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
refactor: remove try/catch/finally from repository worker
This commit is contained in:
parent
813dd1be79
commit
f874ab53e7
1 changed files with 18 additions and 13 deletions
|
@ -20,6 +20,7 @@ async function renovateRepository(repoConfig) {
|
|||
logger.info('Renovating repository');
|
||||
logger.trace({ config }, 'renovateRepository()');
|
||||
let commonConfig;
|
||||
let res;
|
||||
try {
|
||||
config = await initApis(config);
|
||||
config = await initRepo(config);
|
||||
|
@ -40,11 +41,11 @@ async function renovateRepository(repoConfig) {
|
|||
configs[index] = config;
|
||||
}
|
||||
// Combine all the results into one
|
||||
for (const [index, res] of configs.entries()) {
|
||||
for (const [index, entry] of configs.entries()) {
|
||||
if (index === 0) {
|
||||
config = res;
|
||||
config = entry;
|
||||
} else {
|
||||
config.branches = config.branches.concat(res.branches);
|
||||
config.branches = config.branches.concat(entry.branches);
|
||||
}
|
||||
}
|
||||
// istanbul ignore next
|
||||
|
@ -72,21 +73,25 @@ async function renovateRepository(repoConfig) {
|
|||
// Sort by prTitle
|
||||
return a.prTitle < b.prTitle ? -1 : 1;
|
||||
});
|
||||
const res = config.repoIsOnboarded
|
||||
res = config.repoIsOnboarded
|
||||
? await writeUpdates(config)
|
||||
: await ensureOnboardingPr(config);
|
||||
await validatePrs(commonConfig || config);
|
||||
return res;
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
const res = await handleError(config, err);
|
||||
return res;
|
||||
} finally {
|
||||
logger.setMeta({ repository: config.repository });
|
||||
config.branchPrefix = commonConfig
|
||||
? commonConfig.branchPrefix
|
||||
: config.branchPrefix;
|
||||
res = await handleError(config, err);
|
||||
}
|
||||
logger.setMeta({ repository: config.repository });
|
||||
config.branchPrefix = commonConfig
|
||||
? commonConfig.branchPrefix
|
||||
: config.branchPrefix;
|
||||
try {
|
||||
await pruneStaleBranches(config);
|
||||
platform.cleanRepo();
|
||||
logger.info('Finished repository');
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
logger.error(
|
||||
{ err, message: err.message },
|
||||
'Error pruning/cleaning repository'
|
||||
);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue