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

Function resolveGitRoot

src/git-worktrees.ts:93–110  ·  view source on GitHub ↗
(path: string, allowedRoots: string[])

Source from the content-addressed store, hash-verified

91}
92
93async function resolveGitRoot(path: string, allowedRoots: string[]): Promise<string> {
94 try {
95 const output = await git(["rev-parse", "--show-toplevel"], path);
96 return await assertGitRootAllowed(output.trim(), allowedRoots);
97 } catch (error) {
98 if (isGitUnavailable(error)) {
99 throw new GitWorktreeError(
100 "GIT_NOT_AVAILABLE",
101 "Cannot open workspace in worktree mode because Git is not available on this machine.",
102 );
103 }
104
105 throw new GitWorktreeError(
106 "GIT_REPOSITORY_NOT_FOUND",
107 `Cannot open workspace in worktree mode because this path is not inside a Git repository: ${path}. Use mode=\"checkout\" to work directly in this directory, or initialize Git and create an initial commit first.`,
108 );
109 }
110}
111
112async function assertGitRootAllowed(gitRoot: string, allowedRoots: string[]): Promise<string> {
113 try {

Callers 1

createManagedWorktreeFunction · 0.85

Calls 3

assertGitRootAllowedFunction · 0.85
isGitUnavailableFunction · 0.85
gitFunction · 0.70

Tested by

no test coverage detected