Summary
Refactor direct Bun.spawn calls to use the centralized runGitCommand helper for consistency, testability, and maintainability.
Background
During PR #259 code review, @gemini-code-assist identified that several functions still use Bun.spawn directly instead of the new runGitCommand helper introduced in src/lib/git-exec.ts.
Related PR: #259
Review threads:
Tasks
src/lib/git-workflow.ts
src/lib/repo-manager.ts
Benefits
- Consistency: All git commands use the same execution pattern
- Testability: Easier to mock in tests (single point of mocking)
- Maintainability: Centralized error handling and logging
- Debugging: Unified command execution for easier debugging
Example Refactoring
Before:
const proc = Bun.spawn(['git', 'rev-parse', '--absolute-git-dir'], {
stdout: 'pipe',
stderr: 'pipe',
})
const exitCode = await proc.exited
const stdout = await new Response(proc.stdout).text()
After:
import { runGitCommand } from './git-exec'
const result = await runGitCommand(['git', 'rev-parse', '--absolute-git-dir'])
if (result.exitCode !== 0) {
return null
}
return result.stdout.trim()
Acceptance Criteria
Summary
Refactor direct
Bun.spawncalls to use the centralizedrunGitCommandhelper for consistency, testability, and maintainability.Background
During PR #259 code review, @gemini-code-assist identified that several functions still use
Bun.spawndirectly instead of the newrunGitCommandhelper introduced insrc/lib/git-exec.ts.Related PR: #259
Review threads:
Tasks
src/lib/git-workflow.ts
fetchBranch()- Convert to userunGitCommandgetAllLinkedBranches()- Convert to userunGitCommandstartDevelopWorkflow()- Convert to userunGitCommandsrc/lib/repo-manager.ts
getGitDir()- Convert to userunGitCommandisInGitRepo()- Convert to userunGitCommandcloneBareRepo()- Convert to userunGitCommandgetCurrentRepoInfo()- Convert to userunGitCommandBenefits
Example Refactoring
Before:
After:
Acceptance Criteria
Bun.spawncalls for git commands replaced withrunGitCommand