mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-21 18:47:02 +03:00
Resolve external targets from their own repository
Scope explicit sibling targets to their own Git root so caller context and hook manifests cannot suppress required detector guidance. AI assistance disclosure: This commit was prepared with Codex under maintainer direction.
This commit is contained in:
@@ -208,6 +208,18 @@ function resolveProject(cwd = process.cwd(), options = {}) {
|
||||
}
|
||||
}
|
||||
if (!repoRoot) {
|
||||
const targetIsExternal = hasTargetOption(options)
|
||||
&& targetDir !== absCwd
|
||||
&& !isPathInside(targetDir, absCwd);
|
||||
if (targetIsExternal) {
|
||||
const targetRepoRoot = findGitBoundaryRoot(targetDir) || targetDir;
|
||||
return {
|
||||
targetDir,
|
||||
projectRoot: nearestTargetContextRoot(targetRepoRoot, targetDir) || targetRepoRoot,
|
||||
repoRoot: targetRepoRoot,
|
||||
isMonorepo: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
targetDir,
|
||||
projectRoot: nearestTargetContextRoot(absCwd, targetDir) || absCwd,
|
||||
@@ -223,6 +235,18 @@ function resolveProject(cwd = process.cwd(), options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
function findGitBoundaryRoot(startDir) {
|
||||
let dir = path.resolve(startDir);
|
||||
const homeDir = path.resolve(os.homedir());
|
||||
while (true) {
|
||||
if (hasGitBoundary(dir)) return dir;
|
||||
if (dir === homeDir) return null;
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) return null;
|
||||
dir = parent;
|
||||
}
|
||||
}
|
||||
|
||||
function isPathInside(candidate, root) {
|
||||
const rel = path.relative(root, candidate);
|
||||
return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);
|
||||
|
||||
Reference in New Issue
Block a user