"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setCachedModifiedResult = exports.getCachedModifiedResult = void 0;
const logger_1 = require("../../logger");
const repository_1 = require("../cache/repository");
function getCachedModifiedResult(branchName, branchSha) {
    const { branches } = (0, repository_1.getCache)();
    const branch = branches?.find((branch) => branch.branchName === branchName);
    if (branch?.sha === branchSha && branch.isModified !== undefined) {
        return branch.isModified;
    }
    return null;
}
exports.getCachedModifiedResult = getCachedModifiedResult;
function setCachedModifiedResult(branchName, branchSha, isModified) {
    const cache = (0, repository_1.getCache)();
    const branch = cache.branches?.find((branch) => branch.branchName === branchName);
    if (!branch) {
        logger_1.logger.debug(`Branch cache not present for ${branchName}`);
        return;
    }
    if (!branch.sha || branch.sha !== branchSha) {
        branch.sha = branchSha;
    }
    branch.isModified = isModified;
}
exports.setCachedModifiedResult = setCachedModifiedResult;
//# sourceMappingURL=modified-cache.js.map