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

feat(datasource)!: default to the central default versioning #23020

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions lib/modules/datasource/hexpm-bob/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from '../../../logger';
import { ExternalHostError } from '../../../types/errors/external-host-error';
import { cache } from '../../../util/cache/package/decorator';
import { HttpError } from '../../../util/http';
import { id as semverId } from '../../versioning/semver';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
import { datasource, defaultRegistryUrl } from './common';
Expand All @@ -21,6 +22,8 @@ export class HexpmBobDatasource extends Datasource {

override readonly caching = true;

override readonly defaultVersioning = semverId;

@cache({
namespace: `datasource-${datasource}`,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('modules/datasource/index', () => {

describe('getDefaultVersioning()', () => {
it('returns semver if undefined', () => {
expect(getDefaultVersioning(undefined)).toBe('semver');
expect(getDefaultVersioning(undefined)).toBe('semver-coerced');
});
});

Expand Down
5 changes: 3 additions & 2 deletions lib/modules/datasource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { clone } from '../../util/clone';
import { regEx } from '../../util/regex';
import { uniq } from '../../util/uniq';
import { trimTrailingSlash } from '../../util/url';
import { defaultVersioning } from '../versioning';
import * as allVersioning from '../versioning';
import datasources from './api';
import { addMetaData } from './metadata';
Expand Down Expand Up @@ -240,14 +241,14 @@ export function getDefaultVersioning(
datasourceName: string | undefined
): string {
if (!datasourceName) {
return 'semver';
return defaultVersioning.id;
}
const datasource = getDatasourceFor(datasourceName);
// istanbul ignore if: wrong regex manager config?
if (!datasource) {
logger.warn({ datasourceName }, 'Missing datasource!');
}
return datasource?.defaultVersioning ?? 'semver';
return datasource?.defaultVersioning ?? defaultVersioning.id;
}

function applyReplacements(
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/versioning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { VersioningApi, VersioningApiConstructor } from './types';

export * from './types';

const defaultVersioning = semverCoerced;
export const defaultVersioning = semverCoerced;

export const getVersioningList = (): string[] => Array.from(versionings.keys());
/**
Expand Down