0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/cargo/update-locked.ts
rami3l 40721cd0a8
feat(cargo): support range=update-lockfile (#25983)
Co-authored-by: Simon Žlender <pub.git@zlender.si>
Co-authored-by: Simon Žlender <szlend@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-12-05 16:25:31 +00:00

24 lines
854 B
TypeScript

import { logger } from '../../../logger';
import type { UpdateLockedConfig, UpdateLockedResult } from '../types';
import { extractLockFileContentVersions } from './locked-version';
export function updateLockedDependency(
config: UpdateLockedConfig,
): UpdateLockedResult {
const { depName, currentVersion, newVersion, lockFile, lockFileContent } =
config;
logger.debug(
`cargo.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]`,
);
try {
const locked = extractLockFileContentVersions(lockFileContent!);
if (locked?.get(depName)?.find((version) => version === newVersion)) {
return { status: 'already-updated' };
}
return { status: 'unsupported' };
} catch (err) {
logger.debug({ err }, 'cargo.updateLockedDependency() error');
return { status: 'update-failed' };
}
}