Bridge and git gate: repo-root and excluded-dir containment by path.relative, not a hardcoded backslash

github-draft-pr threw 'Target path escapes repo root' on Linux and the gate never excluded its own wrapper dir. One helper, tools/path-within.mjs, replaces the three copies; case-insensitivity now follows the platform's path flavour.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Heimdall 2026-11-12 12:26:37 +00:00
commit 0ffd97baed
5 changed files with 73 additions and 9 deletions

View file

@ -1,7 +1,8 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { dirname, resolve } from "node:path";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { isWithin } from "../path-within.mjs";
const args = process.argv.slice(2);
const wrapperDir = dirname(fileURLToPath(import.meta.url));
@ -59,9 +60,7 @@ function resolveExecutable(command, excludedDir) {
}
function isWithinExcludedDir(candidate, excludedDir) {
const normalizedCandidate = resolve(candidate).toLowerCase();
const normalizedExcludedDir = `${resolve(excludedDir).toLowerCase()}\\`;
return normalizedCandidate.startsWith(normalizedExcludedDir);
return isWithin(excludedDir, candidate, { allowSelf: false });
}
function findGitSubcommand(input) {