Files
renovate/lib/util/git/update-date-cache.ts
Felipe Santos 45ba03e616 fix(git): implement caching for branch update dates (#42948)
* feat(update-date-cache): implement caching for branch update dates

* Try fix coverage

* Fix some test style inconsistencies

* Fix coverage

* Fix test

* Fix test testing the same path
2026-05-01 08:39:20 +00:00

37 lines
917 B
TypeScript

import { DateTime } from 'luxon';
import { logger } from '../../logger/index.ts';
import { getCache } from '../cache/repository/index.ts';
export function getCachedUpdateDateResult(
branchName: string,
branchSha: string | null,
): DateTime | null {
if (!branchSha) {
return null;
}
const cache = getCache();
const branch = cache.branches?.find((br) => br.branchName === branchName);
if (branch?.sha === branchSha && branch.commitTimestamp !== undefined) {
return DateTime.fromISO(branch.commitTimestamp);
}
return null;
}
export function setCachedUpdateDateResult(
branchName: string,
updateDate: DateTime,
): void {
const cache = getCache();
const branch = cache.branches?.find((br) => br.branchName === branchName);
if (!branch) {
logger.debug(`setCachedUpdateDateResult(): Branch cache not present`);
return;
}
branch.commitTimestamp = updateDate.toISO()!;
}