Skip to content

fix: assign commits to closest tag for include-path filtering#1

Open
decofe wants to merge 2 commits intomainfrom
fix-include-paths
Open

fix: assign commits to closest tag for include-path filtering#1
decofe wants to merge 2 commits intomainfrom
fix-include-paths

Conversation

@decofe
Copy link
Copy Markdown

@decofe decofe commented Apr 14, 2026

Description

Rebases DaniPopes/git-cliff@fix-include-paths on top of current main, incorporating maintainer feedback from orhun/git-cliff#711.

Introduces a TaggedCommits struct in its own module (tagged.rs) for better commit-to-tag mapping. When using --include-path/--exclude-path, tagged commits could be filtered out, causing entire tags to be skipped. This PR assigns commits to the closest tag via get_closest() instead of requiring exact matches.

Changes

  • Adds TaggedCommits struct (tagged.rs) with get_closest() for nearest-tag lookup
  • Adds PartialEq/Eq for Tag (compares by name, documented rationale)
  • Updates release processing in lib.rs to use TaggedCommits API instead of raw IndexMap<String, Tag>
  • Replaces exact tag lookups with get_closest() for correct include-path behavior
  • Adds unit tests for all TaggedCommits methods (addressing maintainer feedback)
  • insert() returns bool and no-ops on unknown commits to preserve invariants
  • retain() filters tags map directly (not just tag_indexes) fixing correctness bug
  • append_release() avoids creating a fake empty previous for the first release
  • Restores root_path() for release.repository (was changed to path() by mistake)

Motivation and Context

Fixes orhun#208 — when using --include-path/--exclude-path, tagged commits could be filtered out, causing entire tags to be skipped.

How Has This Been Tested?

  • Unit tests for all TaggedCommits methods (len, is_empty, last, get, get_index, get_closest, contains_commit, get_commit, insert, insert_unknown_commit_is_noop, retain, tags iterator)
  • Existing test suite passes (3 pre-existing shallow-clone failures unrelated to this PR)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (if applicable).
  • I have formatted the code with rustfmt.
    • cargo +nightly fmt --all
  • I checked the lints with clippy.
    • cargo clippy --tests --verbose -- -D warnings
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • cargo test

Co-Authored-By: DaniPopes 57450786+DaniPopes@users.noreply.github.com
Co-Authored-By: zerosnacks 95942363+zerosnacks@users.noreply.github.com

Rebases DaniPopes/git-cliff@fix-include-paths on top of current main.

Introduces TaggedCommits struct in its own module (tagged.rs) for better
commit-to-tag mapping with get_closest() support. Updates all callers in
lib.rs to use the new API. Adds unit tests for all TaggedCommits methods.

Fixes orhun#208.

Co-Authored-By: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d8b4f-670b-76db-9c93-d14f69ef4c55
@decofe decofe force-pushed the fix-include-paths branch from 8253160 to d0d0e8f Compare April 14, 2026 09:41
Comment thread git-cliff-core/src/lib.rs
@zerosnacks zerosnacks changed the title fix: rebase include-paths fix on top of main fix: rebase include-paths fix on top of main from danipopes/git-cliff fork Apr 14, 2026
@zerosnacks zerosnacks marked this pull request as ready for review April 14, 2026 10:06
@zerosnacks zerosnacks requested a review from DaniPopes April 14, 2026 10:06
@decofe decofe changed the title fix: rebase include-paths fix on top of main from danipopes/git-cliff fork fix: assign commits to closest tag for include-path filtering Apr 20, 2026
- Fix tag_indexes doc comment (was backwards about ordering)
- Make insert() return bool and no-op on unknown commits
- Fix repository.path() -> root_path() regression in fill_release
- Fix append_release to not create fake empty previous for first release
- Replace unwrap() with expect() for better panic messages
- Fix retain() to filter tags map directly (was only filtering tag_indexes)
- Add doc comment explaining Tag PartialEq by-name semantics
- Add insert_unknown_commit_is_noop test

Co-Authored-By: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dab72-9199-7439-aefa-ef1efc746210
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.

Relevant tags are missing when using --include-path

2 participants