mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 15:58:48 +00:00
d3b774e8ef
Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-authored-by: Rhys Arkins <rhys@arkins.net>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { getCache } from '../cache/repository';
|
|
|
|
export function getCachedConflictResult(
|
|
targetBranchName: string,
|
|
targetBranchSha: string,
|
|
sourceBranchName: string,
|
|
sourceBranchSha: string
|
|
): boolean | null {
|
|
const { gitConflicts } = getCache();
|
|
if (!gitConflicts) {
|
|
return null;
|
|
}
|
|
|
|
const targetBranchConflicts = gitConflicts[targetBranchName];
|
|
if (targetBranchConflicts?.targetBranchSha !== targetBranchSha) {
|
|
return null;
|
|
}
|
|
|
|
const sourceBranchConflict =
|
|
targetBranchConflicts.sourceBranches[sourceBranchName];
|
|
if (sourceBranchConflict?.sourceBranchSha !== sourceBranchSha) {
|
|
return null;
|
|
}
|
|
|
|
return sourceBranchConflict.isConflicted;
|
|
}
|
|
|
|
export function setCachedConflictResult(
|
|
targetBranchName: string,
|
|
targetBranchSha: string,
|
|
sourceBranchName: string,
|
|
sourceBranchSha: string,
|
|
isConflicted: boolean
|
|
): void {
|
|
const cache = getCache();
|
|
cache.gitConflicts ??= {};
|
|
const { gitConflicts } = cache;
|
|
|
|
let targetBranchConflicts = gitConflicts[targetBranchName];
|
|
if (targetBranchConflicts?.targetBranchSha !== targetBranchSha) {
|
|
gitConflicts[targetBranchName] = {
|
|
targetBranchSha,
|
|
sourceBranches: {},
|
|
};
|
|
targetBranchConflicts = gitConflicts[targetBranchName];
|
|
}
|
|
|
|
const sourceBranchConflict =
|
|
targetBranchConflicts.sourceBranches[sourceBranchName];
|
|
if (sourceBranchConflict?.sourceBranchSha !== sourceBranchSha) {
|
|
targetBranchConflicts.sourceBranches[sourceBranchName] = {
|
|
sourceBranchSha,
|
|
isConflicted,
|
|
};
|
|
}
|
|
}
|