Initialize repository knowledge cache
This commit is contained in:
1 parent
14a30a3695
commit
2d50da41cd
3 files changed
+31
-2
No files matched your search
@@ -430,13 +430,25 @@ function validateAgentChangePath(relativePath: string): void {
|
||||
|
||||
async function assertConflictMarkersRemoved(root: string, conflictFiles: string[]): Promise<void> {
|
||||
for (const relativePath of conflictFiles) {
|
||||
const content = await fs.readFile(safeFilePath(root, relativePath), "utf8");
|
||||
const content = await fs.readFile(safeFilePath(root, relativePath), "utf8").catch((error: unknown) => {
|
||||
if (isFileNotFoundError(error)) {
|
||||
return undefined;
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
if (content === undefined) {
|
||||
continue;
|
||||
}
|
||||
if (/^(?:<<<<<<<|=======|>>>>>>>)(?: |$)/m.test(content)) {
|
||||
throw new Error(`Conflict markers remain in ${relativePath}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isFileNotFoundError(error: unknown): boolean {
|
||||
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
||||
}
|
||||
|
||||
function safeFilePath(root: string, relativePath: string): string {
|
||||
if (path.isAbsolute(relativePath) || relativePath.split(/[\\/]/).includes("..")) {
|
||||
throw new Error(`Unsafe conflict path: ${relativePath}`);
|
||||
|
||||
Reference in new issue
Block a user