contribute
uses tcmts.cli.sync.openRemote, which uses process
Push this branch to a remote and open (or update) a contribution of it into to there.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { branchFor, openRemote, push } from "#codebase/tcmts/cli/sync"; export async function contribute( cb: Codebase, spec: string, o: { to: string; as?: string; title?: string; description?: string; author: string }, ): Promise<{ id: number; created: boolean }> { const { remote } = openRemote(cb, spec); const local = cb.store.branch().name; if ((o.as ?? local) === o.to) throw new Error( `this is ${o.to}: make a branch for the change (\`tcm branch <name>\`, \`tcm switch <name>\`), or push it under another name with --as <name>`, ); // (a contributor's, under @<handle>/) const source = branchFor(await remote.whoami(), o.as ?? local); await push(cb, spec, source, false); return remote.openContribution({ title: o.title ?? source, description: o.description ?? "", source, target: o.to, author: o.author, }); }