0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-05-12 23:51:55 +00:00
renovatebot_renovate/lib/modules/versioning/python/index.ts
Rhys Arkins 67935500d7
feat(versioning): isBreaking (#31859)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-09 08:17:14 +00:00

73 lines
2 KiB
TypeScript

import { api as pep440 } from '../pep440';
import { api as poetry } from '../poetry';
import type { NewValueConfig, VersioningApi } from '../types';
export const id = 'python';
export const displayName = 'Python';
export const urls = [];
export const supportsRanges = false;
function isLessThanRange(version: string, range: string): boolean {
return poetry.isValid(range)
? poetry.isLessThanRange!(version, range)
: pep440.isLessThanRange!(version, range);
}
function isValid(input: string): boolean {
return poetry.isValid(input) || pep440.isValid(input);
}
function matches(version: string, range: string): boolean {
return poetry.isValid(range)
? poetry.matches(version, range)
: pep440.matches(version, range);
}
function getSatisfyingVersion(
versions: string[],
range: string,
): string | null {
return poetry.isValid(range)
? poetry.getSatisfyingVersion(versions, range)
: pep440.getSatisfyingVersion(versions, range);
}
function minSatisfyingVersion(
versions: string[],
range: string,
): string | null {
return poetry.isValid(range)
? poetry.minSatisfyingVersion(versions, range)
: pep440.minSatisfyingVersion(versions, range);
}
function getNewValue(newValue: NewValueConfig): string | null {
return poetry.getNewValue(newValue);
}
function subset(subRange: string, superRange: string): boolean | undefined {
return poetry.isValid(subRange) && poetry.isValid(superRange)
? poetry.subset!(subRange, superRange)
: undefined;
}
export function isBreaking(current: string, version: string): boolean {
const currentMajor = poetry.getMajor(current);
const currentMinor = poetry.getMinor(current);
const newMajor = poetry.getMajor(version);
const newMinor = poetry.getMinor(version);
return !(currentMajor === newMajor && currentMinor === newMinor);
}
export const api: VersioningApi = {
...poetry,
getNewValue,
getSatisfyingVersion,
isBreaking,
isLessThanRange,
isValid,
matches,
minSatisfyingVersion,
subset,
};
export default api;