Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: assign commits to closest tag #711

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

DaniPopes
Copy link
Contributor

@DaniPopes DaniPopes commented Jun 16, 2024

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 #208.

Based on #709 to minimize conflicts.

Motivation and Context

Fixes #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

  • 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.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2024

Codecov Report

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

Project coverage is 42.46%. Comparing base (d0848ff) to head (740ad6e).

Files with missing lines Patch % Lines
git-cliff/src/lib.rs 0.00% 62 Missing ⚠️
git-cliff-core/src/repo.rs 40.63% 38 Missing ⚠️
git-cliff-core/src/tag.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #711      +/-   ##
==========================================
- Coverage   43.08%   42.46%   -0.62%     
==========================================
  Files          21       22       +1     
  Lines        1718     1795      +77     
==========================================
+ Hits          740      762      +22     
- Misses        978     1033      +55     
Flag Coverage Δ
unit-tests 42.46% <20.32%> (-0.62%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DaniPopes
Copy link
Contributor Author

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

@@ -206,11 +206,139 @@ impl Repository {
}
}

/// Stores which commits are tagged with which tags.
#[derive(Debug)]
pub struct TaggedCommits<'a> {
Copy link
Owner

Choose a reason for hiding this comment

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

Let's move this to its own module (tagged.rs or tagged_commit.rs) and add unit tests! 🐻

@@ -324,6 +306,42 @@ fn process_repository<'a>(
Ok(releases)
}

fn fill_release(
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need separate functions for these? I feel like they are additional complexity.

I'm okay with it if we test them though.

@orhun
Copy link
Owner

orhun commented Aug 20, 2024

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

@DaniPopes
Copy link
Contributor Author

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

@orhun
Copy link
Owner

orhun commented Aug 26, 2024

Sounds good :)

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
3 participants