MCPcopy Index your code
hub / github.com/Waishnav/devspace / assertGitRootAllowed

Function assertGitRootAllowed

src/git-worktrees.ts:112–129  ·  view source on GitHub ↗
(gitRoot: string, allowedRoots: string[])

Source from the content-addressed store, hash-verified

110}
111
112async function assertGitRootAllowed(gitRoot: string, allowedRoots: string[]): Promise<string> {
113 try {
114 return assertAllowedPath(gitRoot, allowedRoots);
115 } catch {
116 const canonicalGitRoot = await realpath(gitRoot);
117 for (const allowedRoot of allowedRoots) {
118 const canonicalAllowedRoot = await realpath(allowedRoot).catch(() => undefined);
119 if (!canonicalAllowedRoot || !isPathInsideRoot(canonicalGitRoot, canonicalAllowedRoot)) {
120 continue;
121 }
122
123 const logicalGitRoot = resolve(allowedRoot, relative(canonicalAllowedRoot, canonicalGitRoot));
124 return assertAllowedPath(logicalGitRoot, allowedRoots);
125 }
126
127 return assertAllowedPath(canonicalGitRoot, allowedRoots);
128 }
129}
130
131async function resolveBaseCommit(sourceRoot: string, baseRef: string): Promise<string> {
132 try {

Callers 1

resolveGitRootFunction · 0.85

Calls 2

assertAllowedPathFunction · 0.85
isPathInsideRootFunction · 0.85

Tested by

no test coverage detected