0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/util/git/modified-cache.ts
2023-11-07 15:50:29 +00:00

36 lines
807 B
TypeScript

import { logger } from '../../logger';
import { getCache } from '../cache/repository';
export function getCachedModifiedResult(
branchName: string,
branchSha: string | null,
): boolean | null {
const cache = getCache();
const branch = cache.branches?.find(
(branch) => branch.branchName === branchName,
);
if (branch?.sha === branchSha && branch.isModified !== undefined) {
return branch.isModified;
}
return null;
}
export function setCachedModifiedResult(
branchName: string,
isModified: boolean,
): void {
const cache = getCache();
const branch = cache.branches?.find(
(branch) => branch.branchName === branchName,
);
if (!branch) {
logger.debug(`setCachedModifiedResult(): Branch cache not present`);
return;
}
branch.isModified = isModified;
}