fix: editor command parsing, comprehensive conflict markers, relative git-dir#6
Open
sulthonzh wants to merge 7 commits into
Open
fix: editor command parsing, comprehensive conflict markers, relative git-dir#6sulthonzh wants to merge 7 commits into
sulthonzh wants to merge 7 commits into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes
Editor command parsing bug
spawn(editor, [fullPath])broke when `` contains flags likecode --waitor `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-dirreturns relative paths (e.g..git). Double-resolvingworkingDir + relativeGitDir + filenamecould 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.jsonthat extends base but includes tests.README accuracy
--continue(doesn't exist)--stageand--jsonflags (implemented but undocumented)Tests
15/15 passing (added 6 new tests for marker detection edge cases)