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

Function runPull

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

Source from the content-addressed store, hash-verified

1507// ---------------------------------------------------------------
1508
1509async function runPull(
1510 client: GitClient,
1511 args: string[],
1512 input: GitCliInput,
1513): Promise<GitCliResult> {
1514 // `git pull [<remote>] [<ref>] [--ff-only] [--no-ff]`
1515 const parsed = parseFlags(args, {
1516 "ff-only": { kind: "bool" },
1517 "no-ff": { kind: "bool" },
1518 });
1519 if ("error" in parsed) {
1520 return { stdout: "", stderr: `git pull: ${parsed.error}\n`, exitCode: 129 };
1521 }
1522 if (parsed.positional.length > 2) {
1523 return {
1524 stdout: "",
1525 stderr: `git pull: unexpected argument '${parsed.positional[2]}'\n`,
1526 exitCode: 129,
1527 };
1528 }
1529 const [first, second] = parsed.positional;
1530 const looksLikeUrl = first !== undefined && /^[a-z][a-z0-9+.-]*:\/\//.test(first);
1531 const url = looksLikeUrl ? first : undefined;
1532 const remote = looksLikeUrl ? undefined : first;
1533 const ref = looksLikeUrl ? second : (second ?? undefined);
1534
1535 if (url !== undefined && !isSupportedRemoteUrl(url)) {
1536 return {
1537 stdout: "",
1538 stderr: `git pull: unsupported transport for '${url}'. Only https://, http://, and file:// are supported.\n`,
1539 exitCode: 1,
1540 };
1541 }
1542
1543 const dir = resolveDir(undefined, input.cwd);
1544 try {
1545 await client.pull({
1546 dir,
1547 url,
1548 remote,
1549 ref,
1550 fastForwardOnly: parsed.flags["ff-only"] === true,
1551 fastForward: parsed.flags["no-ff"] === true ? false : undefined,
1552 env: input.env,
1553 });
1554 return { stdout: "", stderr: "", exitCode: 0 };
1555 } catch (cause) {
1556 return mapGitError("pull", cause);
1557 }
1558}
1559
1560// ---------------------------------------------------------------
1561// merge

Callers 1

runGitCliFunction · 0.85

Calls 5

isSupportedRemoteUrlFunction · 0.85
resolveDirFunction · 0.85
mapGitErrorFunction · 0.85
parseFlagsFunction · 0.70
pullMethod · 0.65

Tested by

no test coverage detected