fix(reference): preserve physical failures across late cancellation (#10101)

* fix(reference): preserve physical root admission failures

* fix(reference): retain physical Git read origins during cancellation

* fix(reference): preserve Git directory lookup failures
This commit is contained in:
morluto authored and GitHub committed 2026-11-11 21:39:09 +08:00
1 parent 437109e574
commit 4dedf3e865
5 files changed
+312 -79

No files matched your search

@@ -9,6 +9,13 @@ export interface ReferenceSourceGitDirectory {
readonly commonDirectory: string;
}
/** A cancellation observed by the Git directory locator itself. */
export class ReferenceSourceGitDirectoryCancelled extends Error {
constructor(readonly reason: unknown) {
super("Git directory lookup cancelled", { cause: reason });
}
}
/** Locate the nearest repository without running Git or following config includes. */
export const locateReferenceSourceGitDirectory = async (
root: string,
@@ -17,7 +24,8 @@ export const locateReferenceSourceGitDirectory = async (
): Promise<ReferenceSourceGitDirectory | undefined> => {
let repository = root;
for (;;) {
signal?.throwIfAborted();
if (signal?.aborted === true)
throw new ReferenceSourceGitDirectoryCancelled(signal.reason);
const dotgit = join(repository, ".git");
let metadata;
try {