MCPcopy
hub / github.com/generalaction/emdash / createBranch

Method createBranch

packages/core/src/git/git-repository.ts:245–267  ·  view source on GitHub ↗
(
    options: CreateBranchOptions
  )

Source from the content-addressed store, hash-verified

243 }
244
245 async createBranch(
246 options: CreateBranchOptions
247 ): Promise<Result<{ sequences: GitSequences }, CreateBranchError>> {
248 const name = options.name;
249 const from = options.from ?? 'HEAD';
250
251 if (options.syncWithRemote) {
252 const remote = options.remote ?? 'origin';
253 const fetchResult = await this.fetch(remote);
254 if (!fetchResult.success) {
255 return err({ type: 'fetch_failed', remote, branch: from, error: fetchResult.error });
256 }
257 }
258
259 const base = options.syncWithRemote ? `${options.remote ?? 'origin'}/${from}` : from;
260 try {
261 await this.exec.exec(['branch', '--no-track', '--', name, base]);
262 await this.setBranchBaseConfig(name, base);
263 return ok({ sequences: { refs: await this.refreshRefs() } });
264 } catch (error) {
265 return err(classifyCreateBranchError(error, name, from));
266 }
267 }
268
269 async deleteBranch(
270 branch: string,

Callers

nothing calls this directly

Calls 7

fetchMethod · 0.95
setBranchBaseConfigMethod · 0.95
refreshRefsMethod · 0.95
errFunction · 0.90
okFunction · 0.90
execMethod · 0.65

Tested by

no test coverage detected