MCPcopy
hub / github.com/21st-dev/1code / getDefaultBranch

Function getDefaultBranch

src/main/lib/git/branches.ts:300–316  ·  view source on GitHub ↗
(
	git: ReturnType<typeof simpleGit>,
	remoteBranches: string[],
)

Source from the content-addressed store, hash-verified

298}
299
300async function getDefaultBranch(
301 git: ReturnType<typeof simpleGit>,
302 remoteBranches: string[],
303): Promise<string> {
304 try {
305 const headRef = await git.raw(["symbolic-ref", "refs/remotes/origin/HEAD"]);
306 const match = headRef.match(/refs\/remotes\/origin\/(.+)/);
307 if (match) {
308 return match[1].trim();
309 }
310 } catch {
311 if (remoteBranches.includes("master") && !remoteBranches.includes("main")) {
312 return "master";
313 }
314 }
315 return "main";
316}
317
318async function getCheckedOutBranches(
319 git: ReturnType<typeof simpleGit>,

Callers 1

createBranchesRouterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected