Skip to content

Implement best-in-class 3-way merge using git merge-file for workflow updates#1248

Merged
pelikhan merged 5 commits intomainfrom
copilot/refactor-merge-algorithm-for-markdown
Oct 6, 2025
Merged

Implement best-in-class 3-way merge using git merge-file for workflow updates#1248
pelikhan merged 5 commits intomainfrom
copilot/refactor-merge-algorithm-for-markdown

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 6, 2025

  • Analyze current merge implementation in update_command.go
  • Identify issues with current 2-way merge approach
  • Research git merge-file capabilities
  • Implement proper 3-way merge using git merge-file
  • Download base version from original source ref
  • Create temporary files for base, current, and new versions
  • Execute git merge-file and handle conflicts
  • Update source field before merge to avoid YAML parsing issues
  • Add tests for merge scenarios (clean merge, conflicts, markdown/frontmatter changes)
  • Fix test expectations to match git merge-file behavior
  • Format code and pass linting
  • Test merge functionality manually with real workflows
  • Run full test suite including integration tests
  • Document implementation and benefits
  • Update CLI documentation with merge behavior and conflict resolution

Summary

Successfully replaced the simple 2-way frontmatter overlay with a proper 3-way merge using git merge-file. The implementation now properly handles conflicts and provides clear user guidance for resolution.

Documentation Updates:

  • Added detailed explanation of 3-way merge process
  • Documented conflict detection and resolution workflow
  • Included examples of conflict markers and resolution steps
  • Added conflict notification message examples
Original prompt

Review 3 way merge of markdown in the "update" command and make sure a best-in-class merge algorithm is used (or leverage git).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 6, 2025 09:20
- Replace simple 2-way frontmatter overlay with proper 3-way merge
- Download base version (original from source ref) for merge
- Use git merge-file with --diff3 for best-in-class merge algorithm
- Handle multiple conflict regions (exit codes 1-127)
- Update source field before merging to avoid YAML parsing issues
- Add comprehensive tests for various merge scenarios
- Properly detect and report merge conflicts to users

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Update tests to match git merge-file's actual behavior
- Fix test cases to have truly non-overlapping changes
- Format JavaScript files with prettier
- All unit tests now passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Fully working 3-way merge using git's battle-tested algorithm
- All unit tests passing
- Comprehensive test coverage for various merge scenarios
- Proper conflict detection and user notification
- Clean handling of both frontmatter and markdown changes
- Source field updated before merge to avoid YAML parsing issues

This is a best-in-class merge implementation that:
- Downloads base version for proper 3-way comparison
- Uses git merge-file with --diff3 for clear conflict markers
- Handles exit codes correctly (1-127 for conflicts, >=128 for errors)
- Provides clear user feedback when conflicts occur
- Allows manual conflict resolution using standard git markers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor merge algorithm for optimal markdown handling Implement best-in-class 3-way merge using git merge-file for workflow updates Oct 6, 2025
Copilot AI requested a review from pelikhan October 6, 2025 09:27
Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot

  • more tests
  • update docs

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 6, 2025

@pelikhan Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: ee224c37-4965-4dee-9cee-5d8ceb96fd00

Sorry for the inconvenience!

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Oct 6, 2025

@copilot update docs

- Document new merge behavior with git merge-file
- Explain conflict detection and resolution workflow
- Add examples of clean merge vs. conflicts
- Include conflict marker format and resolution steps
- Document conflict notification messages

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 6, 2025

@copilot update docs

Updated CLI documentation in docs/src/content/docs/tools/cli.md to explain the new 3-way merge behavior, conflict detection, and resolution workflow. Commit: will be included in next push

Copilot AI requested a review from pelikhan October 6, 2025 14:50
@pelikhan pelikhan marked this pull request as ready for review October 6, 2025 15:13
@pelikhan pelikhan merged commit c307ffa into main Oct 6, 2025
13 checks passed
@pelikhan pelikhan deleted the copilot/refactor-merge-algorithm-for-markdown branch October 6, 2025 15:17
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.

2 participants