"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setCachedConflictResult = exports.getCachedConflictResult = void 0;
const logger_1 = require("../../logger");
const repository_1 = require("../cache/repository");
function getCachedConflictResult(branchName, branchSha, baseBranch, baseBranchSha) {
    const cache = (0, repository_1.getCache)();
    if (cache.gitConflicts) {
        delete cache.gitConflicts;
    }
    const branch = cache?.branches?.find((br) => br.branchName === branchName);
    if (branch &&
        branch.baseBranch === baseBranch &&
        branch.baseBranchSha === baseBranchSha &&
        branch.sha === branchSha &&
        branch.isConflicted !== undefined) {
        return branch.isConflicted;
    }
    return null;
}
exports.getCachedConflictResult = getCachedConflictResult;
function setCachedConflictResult(branchName, isConflicted) {
    const cache = (0, repository_1.getCache)();
    const branch = cache?.branches?.find((br) => br.branchName === branchName);
    if (!branch) {
        logger_1.logger.debug(`setCachedConflictResult(): Branch cache not present`);
        return;
    }
    branch.isConflicted = isConflicted;
}
exports.setCachedConflictResult = setCachedConflictResult;
//# sourceMappingURL=conflicts-cache.js.map