mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +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.info('Renovating repository');
|
||||||
logger.trace({ config }, 'renovateRepository()');
|
logger.trace({ config }, 'renovateRepository()');
|
||||||
let commonConfig;
|
let commonConfig;
|
||||||
|
let res;
|
||||||
try {
|
try {
|
||||||
config = await initApis(config);
|
config = await initApis(config);
|
||||||
config = await initRepo(config);
|
config = await initRepo(config);
|
||||||
|
@ -40,11 +41,11 @@ async function renovateRepository(repoConfig) {
|
||||||
configs[index] = config;
|
configs[index] = config;
|
||||||
}
|
}
|
||||||
// Combine all the results into one
|
// Combine all the results into one
|
||||||
for (const [index, res] of configs.entries()) {
|
for (const [index, entry] of configs.entries()) {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
config = res;
|
config = entry;
|
||||||
} else {
|
} else {
|
||||||
config.branches = config.branches.concat(res.branches);
|
config.branches = config.branches.concat(entry.branches);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// istanbul ignore next
|
// istanbul ignore next
|
||||||
|
@ -72,21 +73,25 @@ async function renovateRepository(repoConfig) {
|
||||||
// Sort by prTitle
|
// Sort by prTitle
|
||||||
return a.prTitle < b.prTitle ? -1 : 1;
|
return a.prTitle < b.prTitle ? -1 : 1;
|
||||||
});
|
});
|
||||||
const res = config.repoIsOnboarded
|
res = config.repoIsOnboarded
|
||||||
? await writeUpdates(config)
|
? await writeUpdates(config)
|
||||||
: await ensureOnboardingPr(config);
|
: await ensureOnboardingPr(config);
|
||||||
await validatePrs(commonConfig || config);
|
await validatePrs(commonConfig || config);
|
||||||
return res;
|
|
||||||
} catch (err) /* istanbul ignore next */ {
|
} catch (err) /* istanbul ignore next */ {
|
||||||
const res = await handleError(config, err);
|
res = await handleError(config, err);
|
||||||
return res;
|
}
|
||||||
} finally {
|
|
||||||
logger.setMeta({ repository: config.repository });
|
logger.setMeta({ repository: config.repository });
|
||||||
config.branchPrefix = commonConfig
|
config.branchPrefix = commonConfig
|
||||||
? commonConfig.branchPrefix
|
? commonConfig.branchPrefix
|
||||||
: config.branchPrefix;
|
: config.branchPrefix;
|
||||||
|
try {
|
||||||
await pruneStaleBranches(config);
|
await pruneStaleBranches(config);
|
||||||
platform.cleanRepo();
|
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