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

Function resolveBaseCommit

src/git-worktrees.ts:131–147  ·  view source on GitHub ↗
(sourceRoot: string, baseRef: string)

Source from the content-addressed store, hash-verified

129}
130
131async function resolveBaseCommit(sourceRoot: string, baseRef: string): Promise<string> {
132 try {
133 return (await git(["rev-parse", "--verify", `${baseRef}^{commit}`], sourceRoot)).trim();
134 } catch (error) {
135 if (baseRef === "HEAD") {
136 throw new GitWorktreeError(
137 "GIT_REPOSITORY_HAS_NO_COMMITS",
138 "Cannot open workspace in worktree mode because the repository has no commits yet. Create an initial commit first, or use mode=\"checkout\".",
139 );
140 }
141
142 throw new GitWorktreeError(
143 "GIT_INVALID_BASE_REF",
144 `Cannot open workspace in worktree mode because baseRef ${JSON.stringify(baseRef)} does not resolve to a commit.`,
145 );
146 }
147}
148
149function managedWorktreePath(input: { worktreeRoot: string; repoRoot: string }): string {
150 const repoName = sanitizePathSegment(basename(input.repoRoot)) || "repo";

Callers 1

createManagedWorktreeFunction · 0.85

Calls 1

gitFunction · 0.70

Tested by

no test coverage detected