mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { BitBucketTagsDatasource } from '../bitbucket-tags';
|
|
import { getSourceUrl as githubSourceUrl } from '../github-releases/common';
|
|
import { GithubTagsDatasource } from '../github-tags';
|
|
import { GitlabTagsDatasource } from '../gitlab-tags';
|
|
import { getSourceUrl as gitlabSourceUrl } from '../gitlab-tags/util';
|
|
|
|
import type { DataSource } from './types';
|
|
|
|
// eslint-disable-next-line typescript-enum/no-enum
|
|
export enum GoproxyFallback {
|
|
WhenNotFoundOrGone = ',',
|
|
Always = '|',
|
|
}
|
|
|
|
export function getSourceUrl(
|
|
dataSource?: DataSource | null
|
|
): string | undefined {
|
|
if (dataSource) {
|
|
const { datasource, registryUrl, packageName } = dataSource;
|
|
|
|
if (datasource === GithubTagsDatasource.id) {
|
|
return githubSourceUrl(packageName, registryUrl);
|
|
}
|
|
|
|
if (datasource === GitlabTagsDatasource.id) {
|
|
return gitlabSourceUrl(packageName, registryUrl);
|
|
}
|
|
|
|
if (datasource === BitBucketTagsDatasource.id) {
|
|
return BitBucketTagsDatasource.getSourceUrl(packageName, registryUrl);
|
|
}
|
|
}
|
|
|
|
// istanbul ignore next
|
|
return undefined;
|
|
}
|