makeBranch
uses tcmts.studio.branchingCodebase, which uses tcmts.share.servedCodebase, which uses process
Make the branch name from the studio's own, as tcm branch <name> does; with work, switch to it too
(switchBranch). What it said.
import { HttpError } from "#codebase/tcmts/server"; import { BRANCH_NAME, branchingCodebase, runTcm, switchBranch, tcmSaid } from "#codebase/tcmts/studio"; export async function makeBranch(name: string, work: boolean): Promise<string> { const cb = branchingCodebase(); const want = name.trim(); if (!BRANCH_NAME.test(want)) throw new HttpError(400, `${want || "That"} isn't a branch name.`); const out = tcmSaid(await runTcm(cb.lay.root, ["branch", want], { branch: true }), "tcm branch"); return work ? `${out}\n${await switchBranch(want)}` : out; }
uses
- tcmts.server.HttpError
- tcmts.studio.BRANCH_NAME
- tcmts.studio.branchingCodebase
- tcmts.studio.runTcm
- tcmts.studio.switchBranch
- tcmts.studio.tcmSaid