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 6 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

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 16.07143% with 141 lines in your changes missing coverage. Please review.

Project coverage is 36.61%. Comparing base (dabe716) to head (302f28a).
Report is 33 commits behind head on main.

Files Patch % Lines
git-cliff/src/lib.rs 0.00% 90 Missing ⚠️
git-cliff-core/src/repo.rs 34.25% 48 Missing ⚠️
git-cliff-core/src/changelog.rs 40.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #711      +/-   ##
==========================================
+ Coverage   36.29%   36.61%   +0.32%     
==========================================
  Files          19       19              
  Lines        1455     1497      +42     
==========================================
+ Hits          528      548      +20     
- Misses        927      949      +22     
Flag Coverage Δ
unit-tests 36.61% <16.08%> (+0.32%) ⬆️

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