2022-10-31 05:50:33 +00:00
|
|
|
import { logger } from '../../logger';
|
|
|
|
import { getCache } from '../cache/repository';
|
2022-07-15 07:09:08 +00:00
|
|
|
|
|
|
|
export function getCachedModifiedResult(
|
|
|
|
branchName: string,
|
2023-11-07 15:50:29 +00:00
|
|
|
branchSha: string | null,
|
2022-07-15 07:09:08 +00:00
|
|
|
): boolean | null {
|
2022-10-06 04:37:47 +00:00
|
|
|
const cache = getCache();
|
|
|
|
const branch = cache.branches?.find(
|
2023-11-07 15:50:29 +00:00
|
|
|
(branch) => branch.branchName === branchName,
|
2022-10-06 04:37:47 +00:00
|
|
|
);
|
2022-07-15 07:09:08 +00:00
|
|
|
|
2022-09-20 09:43:14 +00:00
|
|
|
if (branch?.sha === branchSha && branch.isModified !== undefined) {
|
|
|
|
return branch.isModified;
|
2022-07-15 07:09:08 +00:00
|
|
|
}
|
|
|
|
|
2022-09-20 09:43:14 +00:00
|
|
|
return null;
|
2022-07-15 07:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function setCachedModifiedResult(
|
|
|
|
branchName: string,
|
2023-11-07 15:50:29 +00:00
|
|
|
isModified: boolean,
|
2022-07-15 07:09:08 +00:00
|
|
|
): void {
|
|
|
|
const cache = getCache();
|
2022-09-20 09:43:14 +00:00
|
|
|
const branch = cache.branches?.find(
|
2023-11-07 15:50:29 +00:00
|
|
|
(branch) => branch.branchName === branchName,
|
2022-09-20 09:43:14 +00:00
|
|
|
);
|
2022-07-15 07:09:08 +00:00
|
|
|
|
2022-09-20 09:43:14 +00:00
|
|
|
if (!branch) {
|
2022-10-06 04:37:47 +00:00
|
|
|
logger.debug(`setCachedModifiedResult(): Branch cache not present`);
|
2022-09-20 09:43:14 +00:00
|
|
|
return;
|
2022-07-15 07:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
branch.isModified = isModified;
|
|
|
|
}
|