Skip to content

test(git-utils): build the .git-as-file fixture from resolve() so it passes on Windows - #727

Merged
zeshi-du merged 1 commit into
mainfrom
fix/git-utils-windows-path
Nov 3, 2026
Merged

zeshi-du merged 1 commit into
mainfrom
fix/git-utils-windows-path

Conversation

@zeshi-du

@zeshi-du zeshi-du commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

This fixes the red Unit Tests (Windows) on main left by #257. The findGitRoot ".git as a file" test now builds its fixture from resolve(), so on Windows it carries the same drive letter as the path the walker resolves.

Closes #726.

flowchart LR
  F["fixture: resolve('/wt') + .git"] --> W["findGitRoot(resolve('/wt')/pkg)"]
  W --> C["compares against the resolved .git path (D:\\wt\\.git on Windows)"]
  C --> OK["returns resolve('/wt')"]
Loading

Before, on main's Windows job:

FAIL src/lib/git-utils.test.ts > findGitRoot > treats .git as a file (worktree or submodule) the same as a directory
AssertionError: expected null to be 'D:\wt'

After, locally (macOS; Windows runs in this PR's CI):

$ npx vitest run src/lib/git-utils.test.ts
      Tests  30 passed (30)

Test-only change.

Summary by CodeRabbit

  • Tests
    • Updated Git root test paths to support resolved paths on Windows.

…passes on Windows

The findGitRoot test compared against join('/wt', '.git'), which lacks the
drive letter the resolved walk produces on Windows, so Unit Tests (Windows)
failed on main after #257.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6e4949f and 4018211.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The findGitRoot test now builds its worktree fixture and mocked .git path from resolve('/wt') instead of using hard-coded paths.

Changes

findGitRoot test fixture

Layer / File(s) Summary
Use resolved paths in test setup
src/lib/git-utils.test.ts
The test derives the worktree fixture and mocked .git location from resolve('/wt').

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other · Severity of issue fixed: Low

Possibly related issues

  • Issue 726 describes the Windows findGitRoot test failure addressed by using resolved fixture paths.

Possibly related PRs

Suggested reviewers: ruili-testsprite

Merge Risk: Minimal · previous review 6e494

No merge-blocking risk remains from this test-only path fixture update.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the test-only change: building the .git-as-file fixture from resolve() to fix Windows path handling.
Linked Issues check Passed [#726] The issue requires the findGitRoot ".git as a file" test fixture to use the drive-letter path that the walker resolves on Windows. At head, the test builds wt = resolve('/wt') and sets `mockE…
Out of Scope Changes check Passed The whole-PR diff (merge base d9d942f to head 6e4949f) changes only src/lib/git-utils.test.ts, in the single 'treats .git as a file' test. The edits replace the hard-coded /wt fixture paths with val…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

[#726] The issue requires the findGitRoot ".git as a file" test fixture to use the drive-letter path that the walker resolves on Windows. At head, the test builds wt = resolve('/wt') and sets mockExists to match join(wt, '.git'). It calls findGitRoot(join(wt, 'pkg'), ...) and expects wt. findGitRoot (src/lib/git-utils.ts) applies resolve(dir) and then checks join(current, '.git') while walking up. On Windows, resolve('/wt') yields D:\wt, so the mock matches the walker's D:\wt\.git probe and the expected value equals the returned root. On POSIX, resolve('/wt') returns /wt, so the behavior is unchanged. The change does not alter the production code path, which the issue states is correct. The author reports a local macOS run (30 passed). The Windows CI result was not available to this assessment; the PASS rests on code analysis of the fixture and walker.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff (merge base d9d942f to head 6e4949f) changes only src/lib/git-utils.test.ts, in the single 'treats .git as a file' test. The edits replace the hard-coded /wt fixture paths with values derived from resolve('/wt') and add a comment explaining the reason. These edits implement the objective of #726 directly. No production code, other tests, or unrelated files are changed. The import of resolve is already used by the test's expectation, so no unrelated dependency change is present.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d9d942f and 6e4949f.

Files selected for processing: 1
  • src/lib/git-utils.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@dukeduke2016
dukeduke2016 force-pushed the fix/git-utils-windows-path branch from 6e4949f to 4018211 Compare November 3, 2026 09:06
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Test Coverage Report

Metric Coverage
Lines 92.35%
Statements 90.21%
Functions 83.85%
Branches 85.32%

@zeshi-du
zeshi-du merged commit 06cc1ff into main Nov 3, 2026
27 checks passed
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.

Unit Tests (Windows) fail on main after #257: findGitRoot fixture lacks the drive letter

2 participants