fix: update integration tests to work with modern Git default branch - #1
Merged
Merged
Conversation
- Replace hardcoded 'config-master' with dynamic branch detection - Use git branch --show-current to get actual branch name - Add better error messages when config file not found - Ensures tests work with both 'main' and 'master' default branches
This commit enhances the git hook management system to work alongside existing prepare-commit-msg hooks instead of overwriting them. Key improvements: - Use delimited sections (# BEGIN/END git-pair) to isolate git-pair logic - Preserve existing hook content when installing/updating hooks - Smart removal that only removes git-pair sections - Complete hook removal only when file contains only git-pair content - Proper spacing and formatting handling New functions: - merge_git_pair_section(): Safely merges git-pair content into existing hooks - remove_git_pair_section(): Removes only git-pair sections from hooks - is_effectively_empty(): Determines if hook content is meaningful Benefits: - Backward compatibility with existing hooks - Team collaboration without hook conflicts - Tool interoperability with other prepare-commit-msg tools - Safe, reversible operations Testing: - Added 9 comprehensive unit tests covering all scenarios - Tests for hook preservation, merging, removal, and edge cases - All existing tests continue to pass
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.
Git Hook Management Improvements
Overview
The git-pair tool has been enhanced with improved git hook management that preserves existing hooks while seamlessly integrating git-pair functionality.
Key Improvements
1. Hook Preservation
prepare-commit-msghooks2. Sectioned Management
# BEGIN git-pairand# END git-pair) to delimit git-pair functionality3. Smart Hook Removal
Implementation Details
Hook Installation Process
prepare-commit-msgalready existsHook Removal Process
# BEGIN git-pairand# END git-pairExample Scenarios
Scenario 1: No Existing Hook
Result: Creates new hook file with shebang and git-pair section
Scenario 2: Existing Hook Present
After
git-pair add John Doe john@example.com:Scenario 3: Clearing Co-authors
When running
git-pair clear:Benefits
Testing
The implementation includes comprehensive tests covering:
All tests pass and the functionality has been validated through both unit tests and integration tests.