mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 18:22:42 +00:00
fix(reference): keep unresolved root and Git directory reads as failures
This commit is contained in:
1 parent
bbc75545ec
commit
1ddb32956a
4 files changed
+58
-7
No files matched your search
@@ -41,20 +41,20 @@ export const locateReferenceSourceGitDirectory = async (
|
||||
// Derived joins and the Git library normalize paths lexically. Admit the
|
||||
// physical directory first, while the source pointer stays in its file.
|
||||
const gitDirectory = await realpath(selectedGitDirectory);
|
||||
let commonDirectory = gitDirectory;
|
||||
let common: string | undefined;
|
||||
try {
|
||||
const common = (await readText(join(gitDirectory, "commondir"))).replace(
|
||||
common = (await readText(join(gitDirectory, "commondir"))).replace(
|
||||
/\r?\n$/u,
|
||||
"",
|
||||
);
|
||||
if (common.length === 0)
|
||||
throw new Error("Invalid Git common-directory pointer");
|
||||
commonDirectory = await realpath(
|
||||
absoluteCallerPath(common, { cwd: gitDirectory }),
|
||||
);
|
||||
} catch (cause: unknown) {
|
||||
if (!hasCode(cause, "ENOENT")) throw cause;
|
||||
}
|
||||
if (common === "") throw new Error("Invalid Git common-directory pointer");
|
||||
const commonDirectory =
|
||||
common === undefined
|
||||
? gitDirectory
|
||||
: await realpath(absoluteCallerPath(common, { cwd: gitDirectory }));
|
||||
return { repository, gitDirectory, commonDirectory };
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user