feat(changelog): Detect nested merged branches#76
Merged
Conversation
Add support for detecting all merged branches including nested merges where branch B merges into branch A, and then A merges into main. Previously, using --first-parent only detected the final merge (A). Now detects both A and B by removing --first-parent and using negative filtering to exclude reverse merges (main→feature). Changes: - Add target_branch input to action.yml (default: main|develop|master) - Remove --first-parent flag from git log commands - Add negative filter: grep -v "Merge branch '(TARGET_BRANCH)' into" - Create test_merged-branches.bats with 12 comprehensive tests Filtering logic: - Excludes: Reverse merges (main→feature) for conflict resolution - Includes: All forward merges (feature→feature and feature→main) Test coverage: - Nested merges (B→A→develop) ✓ - Deep nesting (C→B→A→develop) ✓ - Conflict resolution filtering ✓ - Parallel merges ✓ - Custom target branch patterns ✓ All 41 tests pass (29 existing + 12 new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Address all recommendations from code review to improve documentation and test coverage: 1. Performance Impact (Recommendation 1): - Add dedicated "Nested Merge Detection" section to README - Document performance considerations and tradeoffs - Note: Minimal impact for typical workflows, 1-2s for large histories 2. Document Intentional --first-parent (Recommendation 3): - Add inline comments explaining why changelog uses --first-parent - Clarify that branch detection does NOT use --first-parent - Document the intentional separation of concerns 3. Fix Test Documentation (Recommendation 4): - Remove confusing "positive filtering" reference - Clarify squash-merge vs separate merge commit scenarios 4. Add Default TARGET_BRANCH Test (Recommendation 5): - New test verifies default fallback behavior when unset - Ensures "(main|develop|master)" default works correctly 5. Document Regex Patterns (Recommendation 6): - Update action.yml description with ERE syntax details - Add example: "(release.*|hotfix.*)" for flexible matching - Explain filtering behavior clearly Documentation improvements: - Add nested merge detection to Features section - Update inputs table with target_branch and use_git_lfs - Enhance generate-changelog.sh environment variables docs - Add test_merged-branches.bats to test running instructions - Expand test coverage list with new scenarios All 42 tests pass (29 existing + 13 new) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Improve input naming for better clarity: - Rename: target_branch → exclude_source_branches - New description: Exclude merged commits of given branches - More intuitive: Clearly indicates these branches are excluded when they are the SOURCE of a merge (e.g., main→feature) Changes: - action.yml: Rename input and update description - generate-changelog.sh: Rename TARGET_BRANCH → EXCLUDE_SOURCE_BRANCHES - test_merged-branches.bats: Update all test variable names - README.md: Update documentation with new naming All 42 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
matejsemancik
approved these changes
Nov 21, 2025
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.
Summary
Add support for detecting all merged branches including nested merges where one feature branch merges into another before merging to main.
Example: Branch B merges into branch A, then A merges into develop
feature-Adetectedfeature-Aandfeature-Bdetected ✅Changes
Core Implementation
--first-parentflag for branch name detection to see all merge commitsgrep -v "Merge branch '(EXCLUDE_SOURCE_BRANCHES)' into"--first-parentfor changelog messages (intentionally follows main branch history only)New Features
exclude_source_branches(default:"(main|develop|master)")"(release.*|hotfix.*)"for flexible matchingmain→featurefor conflict resolution)Documentation
Testing
test_merged-branches.batswith 13 comprehensive testsTest Results
Files Changed
action.yml- Addexclude_source_branchesinputgenerate-changelog.sh- Implement nested merge detectiontest_merged-branches.bats- New comprehensive test suite (470 lines)README.md- Documentation updatesTotal: 4 files changed, +533 lines, -11 lines
Breaking Changes
None - fully backward compatible with existing workflows.
🤖 Generated with Claude Code