MCPcopy Index your code
hub / github.com/coder/mux / testGitStatus

Function testGitStatus

src/cli/debug/git-status.ts:48–116  ·  view source on GitHub ↗
(workspaceId: string, workspacePath: string)

Source from the content-addressed store, hash-verified

46}
47
48function testGitStatus(workspaceId: string, workspacePath: string) {
49 console.log("\n" + "=".repeat(80));
50 console.log(`Workspace: ${workspaceId}`);
51 console.log(`Path: ${workspacePath}`);
52 console.log("=".repeat(80));
53
54 try {
55 // Run the git status script
56 const output = execSync(GIT_STATUS_SCRIPT, {
57 cwd: workspacePath,
58 encoding: "utf-8",
59 stdio: ["pipe", "pipe", "pipe"],
60 });
61
62 console.log("\n--- RAW OUTPUT ---");
63 console.log(output);
64
65 // Parse using production function
66 const parsed = parseGitStatusScriptOutput(output);
67
68 if (!parsed) {
69 console.log("\n❌ FAILED: Could not parse script output");
70 return;
71 }
72
73 const {
74 primaryBranch,
75 ahead,
76 behind,
77 dirtyCount,
78 outgoingAdditions,
79 outgoingDeletions,
80 incomingAdditions,
81 incomingDeletions,
82 } = parsed;
83 const dirty = dirtyCount > 0;
84
85 console.log("\n--- PARSED RESULT ---");
86 console.log(
87 `✅ Success: { base: ${primaryBranch}, ahead: ${ahead}, behind: ${behind}, dirty: ${dirty}, outgoing: +${outgoingAdditions}/-${outgoingDeletions}, incoming: +${incomingAdditions}/-${incomingDeletions} }`
88 );
89
90 // Verify with git rev-list
91 console.log("\n--- VERIFICATION (git rev-list) ---");
92 try {
93 const revList = execSync(`git rev-list --left-right --count HEAD...origin/${primaryBranch}`, {
94 cwd: workspacePath,
95 encoding: "utf-8",
96 }).trim();
97
98 const [verifyAhead, verifyBehind] = revList.split(/\s+/).map((n) => parseInt(n, 10));
99 console.log(`git rev-list: ahead=${verifyAhead}, behind=${verifyBehind}`);
100
101 if (verifyAhead !== ahead || verifyBehind !== behind) {
102 console.log("⚠️ WARNING: Mismatch between script output and rev-list!");
103 }
104 } catch (err: unknown) {
105 const error = err as Error;

Callers 1

gitStatusCommandFunction · 0.85

Calls 1

Tested by

no test coverage detected