MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / gitLog

Function gitLog

src/workspaces/git-service.ts:39–59  ·  view source on GitHub ↗
(cwd: string, limit: number)

Source from the content-addressed store, hash-verified

37 * Tab-separated to avoid quoting headaches inside commit subjects.
38 */
39export async function gitLog(cwd: string, limit: number): Promise<GitLogEntry[]> {
40 const n = Math.max(1, Math.min(limit, 500));
41 const { stdout, exitCode, stderr } = await exec(
42 ['log', `--pretty=format:${LOG_FORMAT}`, `-n`, String(n)],
43 cwd,
44 gitOpts(),
45 );
46 if (exitCode !== 0) {
47 throw new Error(`git log exited ${exitCode}: ${stderr.slice(0, 200)}`);
48 }
49 const lines = stdout.split('\n').filter((l) => l.length > 0);
50 return lines.map((line) => {
51 const parts = line.split('\t');
52 return {
53 hash: parts[0] ?? '',
54 relTime: parts[1] ?? '',
55 authorTime: parts[2] ?? '',
56 subject: parts.slice(3).join('\t'),
57 };
58 });
59}
60
61/**
62 * Best-effort branch + working-tree status. `branch --show-current` returns

Callers 1

createWorkspaceRoutesFunction · 0.85

Calls 2

gitOptsFunction · 0.85
execFunction · 0.50

Tested by

no test coverage detected