git-cliff icon indicating copy to clipboard operation
git-cliff copied to clipboard

fix: assign commits to closest tag

Open DaniPopes opened this issue 1 year ago • 5 comments

Description

Previously, when creating releases (assigning commits to tags), a new release was considered only when a tagged commit is encountered. This works fine in most cases, however, when used together with --include-path/--exclude-path, which may filter out one of these tagged commits, the entire tag would be skipped too.

This PR makes sure tags are never skipped by looking up the closest tag instead of trying to find an exact match for a given commit when creating new releases.

Additionally, this PR also fixes the issue where the first (root) commit of the repository was never included in the output when --include-path/--include-path was used.

Both of these issues are described in https://github.com/orhun/git-cliff/issues/208.

Based on https://github.com/orhun/git-cliff/pull/709 to minimize conflicts.

Motivation and Context

Fixes https://github.com/orhun/git-cliff/issues/208.

How Has This Been Tested?

cargo test + manual testing on repositories I use git-cliff on with --include-path, and with the script provided in the issue.

Screenshots / Logs (if applicable)

Types of Changes

  • [x] 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:

  • [x] My code follows the code style of this project.
  • [x] I have updated the documentation accordingly.
  • [x] I have formatted the code with rustfmt.
  • [x] I checked the lints with clippy.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

DaniPopes avatar Jun 16 '24 10:06 DaniPopes

Codecov Report

Attention: Patch coverage is 19.04762% with 102 lines in your changes missing coverage. Please review.

Project coverage is 42.21%. Comparing base (e85888f) to head (1ca80e1).

Files with missing lines Patch % Lines
git-cliff/src/lib.rs 0.00% 62 Missing :warning:
git-cliff-core/src/repo.rs 38.71% 38 Missing :warning:
git-cliff-core/src/tag.rs 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #711      +/-   ##
==========================================
- Coverage   42.85%   42.21%   -0.63%     
==========================================
  Files          21       22       +1     
  Lines        1734     1810      +76     
==========================================
+ Hits          743      764      +21     
- Misses        991     1046      +55     
Flag Coverage Δ
unit-tests 42.21% <19.05%> (-0.63%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jun 16 '24 10:06 codecov-commenter

Keeping as draft as existing tests pass, but I still have to add new ones from the linked issue and some more edge cases I have in mind

DaniPopes avatar Jun 16 '24 13:06 DaniPopes

Hey @DaniPopes are you still interested in working on this?

orhun avatar Aug 20 '24 14:08 orhun

Hey, sorry I haven't been able to allocate more time on this, and I'll be off for a few weeks. Might come back to this in a month or so

DaniPopes avatar Aug 26 '24 14:08 DaniPopes

Sounds good :)

orhun avatar Aug 26 '24 18:08 orhun

ayo what's the progress on this 👀

orhun avatar Jan 22 '25 22:01 orhun

closing due to inactivity

orhun avatar Feb 20 '25 20:02 orhun