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

Function runLsTree

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

Source from the content-addressed store, hash-verified

1025// ---------------------------------------------------------------
1026
1027async function runLsTree(
1028 client: GitClient,
1029 args: string[],
1030 input: GitCliInput,
1031): Promise<GitCliResult> {
1032 const parsed = parseFlags(args, {});
1033 if ("error" in parsed) {
1034 return { stdout: "", stderr: `git ls-tree: ${parsed.error}\n`, exitCode: 129 };
1035 }
1036 if (parsed.positional.length === 0) {
1037 return { stdout: "", stderr: "git ls-tree: missing <tree-ish>\n", exitCode: 129 };
1038 }
1039 if (parsed.positional.length > 2) {
1040 return {
1041 stdout: "",
1042 stderr: `git ls-tree: unexpected argument '${parsed.positional[2]}'\n`,
1043 exitCode: 129,
1044 };
1045 }
1046 const [ref, subpath] = parsed.positional;
1047 const dir = resolveDir(undefined, input.cwd);
1048 try {
1049 const entries = await client.lsTree({ dir, ref, path: subpath });
1050 if (entries.length === 0) return { stdout: "", stderr: "", exitCode: 0 };
1051 // Match real git's `git ls-tree` line format:
1052 // <mode> SP <type> SP <oid> TAB <path>
1053 const lines = entries.map((e) => `${e.mode} ${e.type} ${e.oid}\t${e.path}`);
1054 return { stdout: `${lines.join("\n")}\n`, stderr: "", exitCode: 0 };
1055 } catch (cause) {
1056 return mapGitError("ls-tree", cause);
1057 }
1058}
1059
1060// ---------------------------------------------------------------
1061// branch

Callers 1

runGitCliFunction · 0.85

Calls 4

resolveDirFunction · 0.85
mapGitErrorFunction · 0.85
lsTreeMethod · 0.80
parseFlagsFunction · 0.70

Tested by

no test coverage detected