MCPcopy Create free account
hub / github.com/cloudflare/computer / runAdd

Function runAdd

packages/computer/src/git/cli.ts:542–573  ·  view source on GitHub ↗
(
  client: GitClient,
  args: string[],
  input: GitCliInput,
)

Source from the content-addressed store, hash-verified

540// ---------------------------------------------------------------
541
542async function runAdd(
543 client: GitClient,
544 args: string[],
545 input: GitCliInput,
546): Promise<GitCliResult> {
547 // `git add [-A|--all] [--force] <pathspec>...`
548 const parsed = parseFlags(args, {
549 force: { kind: "bool", alias: ["f"] },
550 all: { kind: "bool", alias: ["A"] },
551 });
552 if ("error" in parsed) {
553 return { stdout: "", stderr: `git add: ${parsed.error}\n`, exitCode: 129 };
554 }
555 const all = parsed.flags.all === true;
556 // `-A` stages the whole tree and needs no pathspec; without it a
557 // missing pathspec is the same no-op error real git prints.
558 if (!all && parsed.positional.length === 0) {
559 return { stdout: "", stderr: "git add: nothing specified, nothing added.\n", exitCode: 129 };
560 }
561 const dir = resolveDir(undefined, input.cwd);
562 try {
563 await client.add({
564 dir,
565 paths: all ? [] : parsed.positional,
566 all,
567 force: parsed.flags.force === true,
568 });
569 } catch (cause) {
570 return mapGitError("add", cause);
571 }
572 return { stdout: "", stderr: "", exitCode: 0 };
573}
574
575// ---------------------------------------------------------------
576// rm

Callers 1

runGitCliFunction · 0.85

Calls 4

resolveDirFunction · 0.85
mapGitErrorFunction · 0.85
parseFlagsFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected