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

Function statusWith

packages/computer/src/git/status.ts:65–88  ·  view source on GitHub ↗
(opts: StatusWithDeps)

Source from the content-addressed store, hash-verified

63}
64
65export async function statusWith(opts: StatusWithDeps): Promise<StatusEntry[]> {
66 const dir = opts.dir ?? "/";
67 let rows: StatusMatrixRow[];
68 try {
69 rows = await opts.git.statusMatrix({ fs: opts.fs, dir, cache: opts.cache });
70 } catch (cause) {
71 if (isNotARepositoryCause(cause)) throw new NotARepositoryError(dir, { cause });
72 throw new GitError("ESTATUSFAIL", `git status failed: ${errorMessage(cause)}`, { cause });
73 }
74
75 const out: StatusEntry[] = [];
76 for (const [path, head, workdir, stage] of rows) {
77 // Skip fully clean rows.
78 if (head === 1 && workdir === 1 && stage === 1) continue;
79 const index = indexCode(head, stage);
80 const worktree = worktreeCode(head, workdir, stage);
81 if (index === " " && worktree === " ") continue;
82 out.push({ path, index, worktree });
83 }
84 // Stable ordering by path. Real git is lexicographic; match it
85 // so a snapshot doesn't churn on cache iteration order.
86 out.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
87 return out;
88}
89
90// Derive the X (index-vs-HEAD) column.
91// HEAD absent, stage present -> A

Callers 2

statusFunction · 0.85
status.test.tsFile · 0.85

Calls 6

isNotARepositoryCauseFunction · 0.85
indexCodeFunction · 0.85
worktreeCodeFunction · 0.85
errorMessageFunction · 0.70
statusMatrixMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected