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

Function addWith

packages/computer/src/git/staging.ts:75–99  ·  view source on GitHub ↗
(opts: AddWithDeps)

Source from the content-addressed store, hash-verified

73}
74
75export async function addWith(opts: AddWithDeps): Promise<void> {
76 const dir = opts.dir ?? "/";
77 if (opts.all) {
78 return addAll(opts, dir);
79 }
80 if (opts.paths.length === 0) return;
81 try {
82 // isomorphic-git 1.27+ accepts an array; older versions only
83 // accept a single string. We pass the array and let it fan
84 // out; the version pinned by the repo (^1.x) supports this.
85 await opts.git.add({
86 fs: opts.fs,
87 dir,
88 filepath: opts.paths,
89 cache: opts.cache,
90 force: opts.force,
91 });
92 } catch (cause) {
93 if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause });
94 if (looksLikePathspecMiss(cause)) {
95 throw new PathspecNotFoundError(firstPathspec(opts.paths), { cause });
96 }
97 throw new GitError("EADDFAIL", `git add failed: ${errorMessage(cause)}`, { cause });
98 }
99}
100
101/**
102 * Stage every working-tree change. Walks the status matrix and

Callers 2

addFunction · 0.85
staging.test.tsFile · 0.85

Calls 6

addAllFunction · 0.85
isNotARepositoryCauseFunction · 0.85
looksLikePathspecMissFunction · 0.85
firstPathspecFunction · 0.85
errorMessageFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected