MCPcopy
hub / github.com/coder/mux / getCurrentBranch

Function getCurrentBranch

src/node/git.ts:66–78  ·  view source on GitHub ↗
(projectPath: string)

Source from the content-addressed store, hash-verified

64}
65
66export async function getCurrentBranch(projectPath: string): Promise<string | null> {
67 try {
68 using proc = execFileAsync("git", ["-C", projectPath, "rev-parse", "--abbrev-ref", "HEAD"]);
69 const { stdout } = await proc.result;
70 const branch = stdout.trim();
71 if (!branch || branch === "HEAD") {
72 return null;
73 }
74 return branch;
75 } catch {
76 return null;
77 }
78}
79
80const FALLBACK_TRUNK_CANDIDATES = ["main", "master", "trunk", "develop", "default"];
81

Callers 2

getProtectedBranchesMethod · 0.90
detectDefaultTrunkBranchFunction · 0.85

Calls 1

execFileAsyncFunction · 0.90

Tested by

no test coverage detected