editableCodebase

tcmts.studio.editableCodebase · #bh6ypo75 · term · runs on the server

uses tcmts.share.servedCodebase, which uses process

The codebase, for changing it from the studio: only the studio's maintainer does, and only on the codebase's own branch (another branch, as the branch menu reads it, is only read).

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { HttpError } from "#codebase/tcmts/server";
import { callerNow, servedCodebase } from "#codebase/tcmts/share";
import { studioCodebase } from "#codebase/tcmts/studio";

export function editableCodebase(): Codebase {
  const { cb } = servedCodebase();
  if (callerNow(cb)?.role !== "maintainer")
    throw new HttpError(403, "Only the studio's maintainer changes the codebase.");
  if (studioCodebase().cb !== cb)
    throw new HttpError(
      409,
      `${studioCodebase().cb.store.branch().name} is only read here: it's changed where it's the codebase's own branch (the branch menu goes back to ${cb.store.branch().name}).`,
    );
  return cb;
}

uses

used by