Files
renovate/lib/util/git/conflicts-cache.ts
T
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00

40 lines
1.0 KiB
TypeScript

import { isNonEmptyObject } from '@sindresorhus/is';
import { logger } from '../../logger/index.ts';
import { getCache } from '../cache/repository/index.ts';
export function getCachedConflictResult(
branchName: string,
branchSha: string,
baseBranch: string,
baseBranchSha: string,
): boolean | null {
const cache = getCache();
const branch = cache?.branches?.find((br) => br.branchName === branchName);
if (
isNonEmptyObject(branch) &&
branch.baseBranch === baseBranch &&
branch.baseBranchSha === baseBranchSha &&
branch.sha === branchSha &&
branch.isConflicted !== undefined
) {
return branch.isConflicted;
}
return null;
}
export function setCachedConflictResult(
branchName: string,
isConflicted: boolean,
): void {
const cache = getCache();
const branch = cache?.branches?.find((br) => br.branchName === branchName);
if (!branch) {
logger.debug(`setCachedConflictResult(): Branch cache not present`);
return;
}
branch.isConflicted = isConflicted;
}