Skip to content

Conversation

@william-stacken
Copy link
Contributor

@william-stacken william-stacken commented Mar 11, 2025

Description

This PR adds the ability to make use of a query param to a remote API, to fetch commits from non-default branches. The query param is derived from the commit range given to git cliff. For example, if the range is v1.0..v1.1, then the param becomes v1.1. If the range is v1.0..HEAD, then the query param is omitted and the default branch is used, as before.

Motivation and Context

Allows git cliff to support trunk-based workflows, meaning that release notes will be correctly generated from hotfix branches that are not indented to be merged into the deefault branch.
Fixes #1050

How Has This Been Tested?

I ran git-cliff prevtag..hotfixtag --config cliff.toml --tag hotfixtag --github-repo my-org/my-private-repo, before and after applying these changes. I got the expected output with these changes, and got no output without them.

I am not able to test the non-GitHub remotes, but I found the equivalent query parameters in their respective docs
gitlab
gitea
bitbucket

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.

@william-stacken william-stacken requested a review from orhun as a code owner March 11, 2025 10:32
@welcome
Copy link

welcome bot commented Mar 11, 2025

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 14.15094% with 91 lines in your changes missing coverage. Please review.

Project coverage is 41.09%. Comparing base (c3e25c3) to head (9a3dce5).

Files with missing lines Patch % Lines
git-cliff/src/lib.rs 0.00% 41 Missing ⚠️
git-cliff-core/src/changelog.rs 48.28% 15 Missing ⚠️
git-cliff-core/src/remote/gitlab.rs 11.12% 8 Missing ⚠️
git-cliff-core/src/remote/bitbucket.rs 0.00% 7 Missing ⚠️
git-cliff-core/src/remote/gitea.rs 0.00% 7 Missing ⚠️
git-cliff-core/src/remote/github.rs 0.00% 7 Missing ⚠️
git-cliff-core/src/remote/mod.rs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1086      +/-   ##
==========================================
- Coverage   41.48%   41.09%   -0.38%     
==========================================
  Files          21       21              
  Lines        1823     1845      +22     
==========================================
+ Hits          756      758       +2     
- Misses       1067     1087      +20     
Flag Coverage Δ
unit-tests 41.09% <14.16%> (-0.38%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

This looks good! Just left some comments @william-stacken

Would be also nice to add a fixture test for this, e.g. c/p from this one to verify the behavior.

@william-stacken
Copy link
Contributor Author

Thanks @orhun!

Would be also nice to add a fixture test for this, e.g. c/p from this one to verify the behavior.

Have added fixure tests now

@william-stacken william-stacken requested a review from orhun April 1, 2025 14:49
Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding the fixtures! Only had some comments about naming etc

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

LGTM, I had some cleanup suggestions (unfortunately I can't push to your branch)

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

@orhun orhun merged commit aec41be into orhun:main Apr 5, 2025
77 checks passed
@welcome
Copy link

welcome bot commented Apr 5, 2025

Congrats on merging your first pull request! ⛰️

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.

Fetch commits from non-default branches on GitHub

3 participants