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

Function formatPorcelainV2

packages/computer/src/git/status.ts:127–144  ·  view source on GitHub ↗
(entries: StatusEntry[])

Source from the content-addressed store, hash-verified

125
126/** Render `entries` as porcelain v2 lines. */
127export function formatPorcelainV2(entries: StatusEntry[]): string {
128 // git's porcelain v2 uses headers per record and mode/oid
129 // fields we don't compute. We emit a simplified shape that
130 // matches the v2 *changed-files* line prefix (`1 <XY> ...`)
131 // and the untracked prefix (`? <path>`) — enough for a CLI
132 // consumer that just wants a programmatic list. The full
133 // header-with-mtime form is deferred until a caller needs it.
134 if (entries.length === 0) return "";
135 const lines: string[] = [];
136 for (const e of entries) {
137 if (e.worktree === "?") {
138 lines.push(`? ${e.path}`);
139 } else {
140 lines.push(`1 ${e.index}${e.worktree} ${e.path}`);
141 }
142 }
143 return `${lines.join("\n")}\n`;
144}
145
146/**
147 * Render `entries` as porcelain v1 lines (`XY <path>`). Identical

Callers 2

status.test.tsFile · 0.85
runStatusFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected