Skip to content

fix: editor command parsing, comprehensive conflict markers, relative git-dir#6

Open
sulthonzh wants to merge 7 commits into
mainfrom
fix/editor-parsing-conflict-markers-merge-info
Open

fix: editor command parsing, comprehensive conflict markers, relative git-dir#6
sulthonzh wants to merge 7 commits into
mainfrom
fix/editor-parsing-conflict-markers-merge-info

Conversation

@sulthonzh

Copy link
Copy Markdown
Owner

Fixes

Editor command parsing bug

spawn(editor, [fullPath]) broke when `` contains flags like code --wait or `subl -w`. The entire string was passed as the command name, causing spawn to fail. Added `parseEditorCommand()` that properly splits command from flags while respecting quoted paths.

Incomplete conflict marker detection

hasConflictMarkers() only checked for <<<<<<< — missing orphan =======/>>>>>>> from partial manual edits and ||||||| from diff3-style conflicts. A user could delete one marker and the tool would report "resolved" even with remaining markers. Now checks all four marker types at line start (avoids false positives from string literals).

Relative git-dir in getMergeInfo

revparse --git-dir returns relative paths (e.g. .git). Double-resolving workingDir + relativeGitDir + filename could produce wrong paths on some systems. Fixed to resolve to absolute first.

Test config

ts-jest was failing with TS2697 because tsconfig excludes test files. Added tsconfig.test.json that extends base but includes tests.

README accuracy

  • Removed false claim about --continue (doesn't exist)
  • Added docs for --stage and --json flags (implemented but undocumented)
  • Updated conflict marker description

Tests

15/15 passing (added 6 new tests for marker detection edge cases)

sulthonzh and others added 7 commits June 8, 2026 00:26
… git-dir, tests

- Editor command parsing: spawn() broke on editors with flags like
  'code --wait' or 'subl -w' because the entire string was passed as
  the command. Added parseEditorCommand() to properly split command
  and flags while respecting quoted paths.

- Conflict marker detection: only checked for '<<<<<<<' which missed
  orphan ======= and >>>>>>> markers from partial manual edits, and
  ||||||| markers from diff3-style conflicts. Now checks all four
  marker types at line start to avoid false positives from string
  literals.

- getMergeInfo: revparse --git-dir can return relative paths like
  '.git'. Double-resolving (workingDir + relativeGitDir + filename)
  could produce wrong paths. Fixed to resolve gitDir to absolute
  first.

- ts-jest config: test files were excluded from tsconfig causing
  TS2697 errors. Added tsconfig.test.json that extends base but
  includes test files.

- README: removed false 'Continue/abort' claim, added docs for
  --stage and --json flags, updated conflict marker description.

- Added 6 new tests covering orphan markers, diff3 style, and
  false positive prevention.
…and parsing (#7)

- isMergeInProgress only checked index==='U' which misses AA, DD, AU, UA,
  DU, UD unmerged states during rebases/cherry-picks. Now checks both
  index and working_dir for all unmerged codes.
- countConflicts regex required trailing text after <<<<<<< so bare marker
  lines returned 0 while hasConflictMarkers returned true. Fixed to match
  bare markers too.
- hasConflictMarkers now checks all four marker types (<<<<<<<, =======,
  >>>>>>>, |||||||) at line start, avoiding false positives from marker
  text inside string literals or documentation.
- openInEditor now properly parses EDITOR with flags (e.g. 'code --wait')
  instead of passing the entire string as the command name to spawn().

Co-authored-by: Sulthonzh <sulthonzh@users.noreply.github.com>
* fix: merge status detection, conflict marker consistency, editor command parsing

- isMergeInProgress only checked index==='U' which misses AA, DD, AU, UA,
  DU, UD unmerged states during rebases/cherry-picks. Now checks both
  index and working_dir for all unmerged codes.
- countConflicts regex required trailing text after <<<<<<< so bare marker
  lines returned 0 while hasConflictMarkers returned true. Fixed to match
  bare markers too.
- hasConflictMarkers now checks all four marker types (<<<<<<<, =======,
  >>>>>>>, |||||||) at line start, avoiding false positives from marker
  text inside string literals or documentation.
- openInEditor now properly parses EDITOR with flags (e.g. 'code --wait')
  instead of passing the entire string as the command name to spawn().

* fix: editor non-zero exit still validates resolution, add --cwd support

- Fix: resolveFile() now validates file content even when editor exits
  with non-zero code (e.g. vim swap file warnings). Previously the tool
  reported failure without checking if the user actually resolved the
  conflict.

- Fix: ConflictResolver accepts GitOperations instance instead of
  hardcoding new GitOperations(). This ensures cwd is propagated
  correctly when the --cwd option is used.

- Add: --cwd CLI option to run against a different repository directory.
  GitOperations constructor already supported this but it was never
  exposed in the CLI.

- Fix: getConflictedFiles() no longer makes an unnecessary git.status()
  call whose result was discarded.

- Fix: getMergeInfo() calls revparse --git-dir only once instead of
  twice, reusing the resolved absolute path.

- Fix: isMergeInProgress() now detects rebase conflicts (checks
  .git/rebase-merge directory) and cherry-pick conflicts (checks
  .git/CHERRY_PICK_HEAD), not just merge conflicts.

- Fix: getMergeInfo() reads rebase-merge/head-name during rebases
  to show the correct branch being rebased.

---------

Co-authored-by: Sulthonzh <sulthonzh@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI Code Review ✅

No issues found. LGTM!

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