MCPcopy Create free account
hub / github.com/Noumena-Network/code / hasWorktreeChanges

Function hasWorktreeChanges

src/utils/worktree.ts:1158–1187  ·  view source on GitHub ↗
(
  worktreePath: string,
  headCommit: string,
)

Source from the content-addressed store, hash-verified

1156 * — callers use this to decide whether to remove a worktree, so fail-closed.
1157 */
1158export async function hasWorktreeChanges(
1159 worktreePath: string,
1160 headCommit: string,
1161): Promise<boolean> {
1162 const { code: statusCode, stdout: statusOutput } =
1163 await execFileNoThrowWithCwd(gitExe(), ['status', '--porcelain'], {
1164 cwd: worktreePath,
1165 })
1166 if (statusCode !== 0) {
1167 return true
1168 }
1169 if (statusOutput.trim().length > 0) {
1170 return true
1171 }
1172
1173 const { code: revListCode, stdout: revListOutput } =
1174 await execFileNoThrowWithCwd(
1175 gitExe(),
1176 ['rev-list', '--count', `${headCommit}..HEAD`],
1177 { cwd: worktreePath },
1178 )
1179 if (revListCode !== 0) {
1180 return true
1181 }
1182 if (parseInt(revListOutput.trim(), 10) > 0) {
1183 return true
1184 }
1185
1186 return false
1187}
1188
1189/**
1190 * Fast-path handler for --worktree --tmux.

Callers 1

cleanupWorktreeIfNeededFunction · 0.85

Calls 1

execFileNoThrowWithCwdFunction · 0.85

Tested by

no test coverage detected