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

Function runGitCli

packages/computer/src/git/cli.ts:59–152  ·  view source on GitHub ↗
(
  client: GitClient,
  input: GitCliInput,
  _options: RunGitCliOptions = {},
)

Source from the content-addressed store, hash-verified

57}
58
59export async function runGitCli(
60 client: GitClient,
61 input: GitCliInput,
62 _options: RunGitCliOptions = {},
63): Promise<GitCliResult> {
64 // Strip leading global options (currently only `-C <path>`)
65 // before the subcommand. Real git accepts these between `git`
66 // and the subcommand; agents lean on `-C` to avoid changing
67 // process cwd. The path rewrites the effective cwd that each
68 // subcommand's `dir` default resolves against.
69 const global = parseGlobalOptions(input.argv, input.cwd);
70 if ("error" in global) {
71 return { stdout: "", stderr: `git: ${global.error}\n`, exitCode: 129 };
72 }
73 const argv = global.argv;
74 if (argv.length === 0) {
75 return printHelp();
76 }
77 input = global.cwd === input.cwd ? input : { ...input, cwd: global.cwd };
78 const [sub, ...rest] = argv;
79 switch (sub) {
80 case "help":
81 case "--help":
82 case "-h":
83 return printHelp();
84 case "version":
85 case "--version":
86 return printVersion();
87 case "clone":
88 return await runClone(client, rest, input);
89 case "diff":
90 return await runDiff(client, rest, input);
91 case "init":
92 return await runInit(client, rest, input);
93 case "status":
94 return await runStatus(client, rest, input);
95 case "add":
96 return await runAdd(client, rest, input);
97 case "rm":
98 return await runRm(client, rest, input);
99 case "commit":
100 return await runCommit(client, rest, input);
101 case "log":
102 return await runLog(client, rest, input);
103 case "show":
104 return await runShow(client, rest, input);
105 case "rev-parse":
106 return await runRevParse(client, rest, input);
107 case "symbolic-ref":
108 return await runSymbolicRef(client, rest, input);
109 case "ls-files":
110 return await runLsFiles(client, rest, input);
111 case "ls-tree":
112 return await runLsTree(client, rest, input);
113 case "branch":
114 return await runBranch(client, rest, input);
115 case "tag":
116 return await runTag(client, rest, input);

Callers 2

cliFunction · 0.85
cli.test.tsFile · 0.85

Calls 15

parseGlobalOptionsFunction · 0.85
printHelpFunction · 0.85
printVersionFunction · 0.85
runCloneFunction · 0.85
runInitFunction · 0.85
runStatusFunction · 0.85
runAddFunction · 0.85
runRmFunction · 0.85
runCommitFunction · 0.85
runLogFunction · 0.85
runShowFunction · 0.85
runRevParseFunction · 0.85

Tested by

no test coverage detected