Skip to content

test: add unit tests for lib/git.ts (22 tests)#117

Open
TerminalGravity wants to merge 3 commits intomainfrom
test/git-lib-coverage
Open

test: add unit tests for lib/git.ts (22 tests)#117
TerminalGravity wants to merge 3 commits intomainfrom
test/git-lib-coverage

Conversation

@TerminalGravity
Copy link
Collaborator

@TerminalGravity TerminalGravity commented Mar 5, 2026

Adds comprehensive test coverage for src/lib/git.ts — the core module every tool depends on.

22 tests covering:

  • run(): array args, string splitting, timeout handling, stderr fallback, ENOENT, generic failures
  • shell(): basic execution, error handling, custom timeout
  • All convenience functions: getBranch, getStatus, getRecentCommits, getLastCommit, getLastCommitTime, getStagedFiles
  • Fallback logic in getDiffFiles() and getDiffStat()

@TerminalGravity
Copy link
Collaborator Author

Nice — 22 tests for the core git module is solid coverage. Good to see the edge cases (SIGTERM, ENOENT, stderr fallback) tested. Once #116 lands with the new shell() helper, we should add tests for that too since it has its own error handling.

Copy link
Collaborator Author

@TerminalGravity TerminalGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22 tests for git.ts — great coverage. The vi.mock isolation is exactly right for this kind of lib. CI green on both Node 20 and 22. This is ready to merge. 🚀

@TerminalGravity TerminalGravity force-pushed the test/git-lib-coverage branch from f66a890 to 1f2a483 Compare March 9, 2026 01:45
@TerminalGravity TerminalGravity changed the title test: add unit tests for git.ts lib (22 tests) test: add comprehensive tests for lib/git.ts (25 tests) Mar 9, 2026
…tools

Fixes the remaining tools listed in #215 where run() was being called
with shell syntax (pipes, redirects, non-git commands). run() uses
execFileSync('git', args) — no shell, always prepends 'git'.

Changes:
- Add shell() helper to src/lib/git.ts (execSync with shell support)
- verify-completion: use shell() for tsc/build, readFileSync for package.json, array args for git diff
- clarify-intent: use shell() for tsc and find commands
- session-handoff: use shell() for command -v and gh pr list
- audit-workspace: use run() with array args for git diff, shell() for find
- sharpen-followup: use run() with array args for git diff/status
- enrich-agent-task: use shell() for piped git ls-files, readFileSync for head
- sequence-tasks: use shell() for piped git ls-files
- checkpoint: use run() with array args for git add/reset, shell() for compound command
- scope-work: use run() with array args for git status/diff, shell() for piped ls-files

Closes #215
Shows real input/output examples for preflight_check, prompt_score,
scope_work, estimate_cost, log_correction, and search_history.
Includes workflow tip for automatic preflight via CLAUDE.md.
Covers run(), shell(), and all convenience functions including
error handling, timeout behavior, fallback logic in getDiffFiles
and getDiffStat.
@TerminalGravity TerminalGravity changed the title test: add comprehensive tests for lib/git.ts (25 tests) test: add unit tests for lib/git.ts (22 tests) Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant