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

Function getGitEligibility

src/git.ts:33–57  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

31}
32
33export async function getGitEligibility(cwd: string): Promise<GitEligibility> {
34 try {
35 await git(cwd, ["rev-parse", "--is-inside-work-tree"]);
36 } catch {
37 return {
38 ok: false,
39 reason: "not_git",
40 message: "workspace is not inside a git repository",
41 };
42 }
43
44 const gitRoot = (await git(cwd, ["rev-parse", "--show-toplevel"])).stdout.trim();
45 try {
46 await git(gitRoot, ["rev-parse", "--verify", "--quiet", "HEAD^{commit}"]);
47 } catch {
48 return {
49 ok: false,
50 gitRoot,
51 reason: "no_head",
52 message: "repository has no HEAD commit",
53 };
54 }
55
56 return { ok: true, gitRoot };
57}
58
59export function safeWorkspaceRefSegment(workspaceId: string): string {
60 const safe = workspaceId.replace(/[^A-Za-z0-9._-]/g, "-");

Callers 1

initializeWorkspaceFunction · 0.85

Calls 1

gitFunction · 0.70

Tested by

no test coverage detected