Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(changelog): Simplify platform dispatch #23044

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions lib/workers/repository/update/pr/changelog/index.ts
Original file line number Diff line number Diff line change
@@ -26,29 +26,23 @@ export async function getChangeLogJSON(
`Fetching changelog: ${sourceUrl} (${currentVersion} -> ${newVersion})`
);

let res: ChangeLogResult | null = null;

const platform = detectPlatform(sourceUrl);

switch (platform) {
case 'gitlab':
res = await sourceGitlab.getChangeLogJSON(config);
break;
case 'github':
res = await sourceGithub.getChangeLogJSON(config);
break;
if (platform === 'github') {
return await sourceGithub.getChangeLogJSON(config);
}

default:
logger.info(
{ sourceUrl, hostType: platform },
'Unknown platform, skipping changelog fetching.'
);
break;
if (platform === 'gitlab') {
return await sourceGitlab.getChangeLogJSON(config);
}

return res;
logger.info(
{ sourceUrl, hostType: platform },
'Unknown platform, skipping changelog fetching.'
);
} catch (err) /* istanbul ignore next */ {
logger.error({ config, err }, 'getChangeLogJSON error');
return null;
}

return null;
}