GitNexus/gitnexus/src
Gergő Magyar 114d5304d9
fix(mcp): avoid git from non-repo cwd in sibling cwd match (#1138) (#1293)
* fix(mcp): avoid git shellout from non-repo cwd for sibling match

checkCwdMatch used getGitRoot(cwd), which runs git rev-parse from the
launch cwd (often \C:\Users\gergo in MCP stdio). Resolve the cwd git root via
ancestor .git checks first, then keep existing remote-based sibling
logic.

Fixes #1138

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(mcp): address PR #1293 review follow-ups

Three test gaps flagged by review on the #1138 fix:

- sibling-clone-drift.test.ts: the existing "non-git cwd" test only
  asserted match=none, which the pre-fix code also returned (by
  silently failing the spawn). Wrap child_process / node:child_process
  with passthrough vi.fn() spies and assert no execSync/execFileSync
  call is recorded when checkCwdMatch runs against a non-git cwd, so a
  regression that re-introduces the spawn fails loudly.
- git.test.ts: add coverage for findGitRootByDotGit's three untested
  inputs — a `.git` FILE (linked worktree / submodule), a path that
  does not exist, and a file path inside a repo (must walk from the
  parent dir). Each asserts no subprocess was spawned.

No production code changes. Test additions only.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-03 09:17:12 +01:00
..
cli fix(cli): keep GitNexus ignores inside .gitnexus (#1248) 2026-05-01 16:46:05 +01:00
config feat(ingestion): GITNEXUS_INDEX_TEST_DIRS opt-in for __tests__ / __mocks__ (#771) (#1046) 2026-04-23 13:49:06 +01:00
core fix(mcp): avoid git from non-repo cwd in sibling cwd match (#1138) (#1293) 2026-05-03 09:17:12 +01:00
lib feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
mcp feat(mcp): add tool safety annotations (#1127) 2026-05-03 09:06:41 +01:00
server fix(serve): serve web UI at root path instead of 404 (#1048) 2026-04-27 13:17:40 +01:00
storage fix(mcp): avoid git from non-repo cwd in sibling cwd match (#1138) (#1293) 2026-05-03 09:17:12 +01:00
types feat(ingestion): language-agnostic heritage extractor with config+factory pattern (#890) 2026-04-17 17:51:17 +01:00