-
-
Notifications
You must be signed in to change notification settings - Fork 263
feat(context): add release commit range #1123
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
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1123 +/- ##
==========================================
- Coverage 41.09% 41.08% -0.00%
==========================================
Files 21 22 +1
Lines 1845 1860 +15
==========================================
+ Hits 758 764 +6
- Misses 1087 1096 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
working on it :D |
0c861bc to
132a847
Compare
|
i am unsure how to fix that timeout. is this flaky? |
|
That links check should be fine... I'll take care of it later |
orhun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the implementation!
I had some comments and ideas :)
git-cliff-core/src/commit_range.rs
Outdated
| from_short: from.short_id.clone(), | ||
| to_short: to.short_id.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking maybe we can remove the short variants... the templating can be used to trim them anyways.
e.g.
{{ commit_range.to | truncate(length=7, end="") }}
Also I have another idea which might change the whole implementation but... maybe adding this to the commit object would be cleaner?
e.g.
{{ commit.range.to | truncate(length=7, end="") }}
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking maybe we can remove the short variants... the templating can be used to trim them anyways.
Short ids aren't necessarily unique when just truncated. I'd consider using the actual short id coming from git as more robust.
Also I have another idea which might change the whole implementation but... maybe adding this to the commit object would be cleaner?
I'm not sure i can follow? The commit has no idea about a range, or does it? Or do you mean, instead of having the range on the release, have it on every commit in the release? I think i'd consider that counterintuitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah sorry, my bad. I was a bit confused there. It definitely does not belong to commit object :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short ids aren't necessarily unique when just truncated. I'd consider using the actual short id coming from git as more robust.
I'd like to double down on this though... We don't have 2 variants (short, long) in the commit object itself and it might lead to inconsistencies (in very rare cases) if we go with short-long here. So I'd prefer we only go with the long variant here.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to double down :D (one last try).
What kind of inconsistencies?
I'd rather change e.g. the commit in the context to be an object with long+short (that'd be breaking though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of inconsistencies?
You know, we'll be supporting short hashes in one variable (commit_range) but not for the other (commit) which is not great.
The reason why I don't like supporting short commit hashes is because 7 characters is not long enough and it's more probable that two entirely different commits might belong to the same short hash.
Even worse, you can override the first 7 digits of a commit hash with a tool like lucky-commit:
$ git log
1f6383a Some commit
$ lucky_commit
$ git log
0000000 Some commit
So you can have a repo with all 000000 ids, see this git history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, we'll be supporting short hashes in one variable (commit_range) but not for the other (commit) which is not great.
That i absolutely understand, hence my proposition to also add it to the commit itself. But one could also argue that commit and commit_range are different use cases with different needs.
The reason why I don't like supporting short commit hashes is because 7 characters is not long enough and it's more probable that two entirely different commits might belong to the same short hash.
That is exactly my point, just from a different perspective :D. This PR does make use of git_object_short_id to circumvent that (see here)
Sorry for being so persistent. You can just put your foot down and say "Please remove the short id"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try playing tie-breaker ;)
I'd remove the short variants too. We are talking about configuration here. I don't see a point in ommitting a few bytes here. Putting in the long hash doesn't hurt and is more expressive.
Having only one set simplifies both the code and the documentation too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey again, needed to take some break due to a small injury but I'm hoping to get this merged before the release soon :)
So I think we should go without short hashes here and rebase on main to fix the conflicts. The rest should be ready.
@jdrst do you mind incorporating these changes? 😊
e22b038 to
1b8ecf8
Compare
|
We need to rebase on |
|
Hey, no problem! I'm currently on vacation though. I could offer some time within the week after the next (so somewhere between 28.4 and 2.5). Does that still fit your timeframe?
If not, i think you have editing rights, so if it's really pressing you could do it yourself. The rebase was uncomplicated, i just didn't push it yet :/
…On April 20, 2025 9:48:24 PM GMT+02:00, "Orhun Parmaksız" ***@***.***> wrote:
@orhun commented on this pull request.
> + from_short: from.short_id.clone(),
+ to_short: to.short_id.clone(),
Hey again, needed to take some break due to a small injury but I'm hoping to get this merged before the release soon :)
So I think we should go without short hashes here and rebase on `main` to fix the conflicts. The rest should be ready.
@jdrst do you mind incorporating these changes? 😊
--
Reply to this email directly or view it on GitHub:
#1123 (comment)
You are receiving this because you were mentioned.
Message ID: ***@***.***>
|
|
Hey that works, I also tried to do changes here but I can't push to your branch :/ |
git-cliff-core/src/range.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move the entirety to the commit module I think.
git-cliff/src/lib.rs
Outdated
| // Set the commit ranges for all releases | ||
| for release in &mut releases { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that we use an already existing loop for this instead of looping through releases again?
e.g. we can set this in
git-cliff/git-cliff/src/lib.rs
Line 302 in aec41be
| for git_commit in commits.iter().rev() { |
Maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have a look. From what i remember it would've needed a lot of branching/complicated logic because we don't know all of the commits (or the release) we're in until everything is added (and then we can only add it before we switch to the previous release).
I think i opted for this because it is O(n) with n being the number of releases. That should still be fine even with lots of releases.
/edit: formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at process_submodules. It does the same thing because it also needs to have the first and last commit of a release. Maybe you can merge the two loops?
I just turned it off and on again. Maybe it broke because i accidentally force pushed no changes in between and this PR got closed automatically? |
|
No it didn't work :/ Maybe you have branch protection on on |
no idea.. i just forked. no branch protection active. the hint even states
i just added you as contributor.. |
|
Ok I just pushed a commit to there... it doesn't show up in this PR though. What is going on... |
|
Ok I messed up something |
|
Can we maybe create a new branch and open a new PR from there? Creating a PR from the |
aight, will do next week. you could upload a patch here or smth. |
|
The changes are in the |
currently rebasing, cleaning up and incorporating requested changes, will pr soon. |
|
yup! thanks |

Description
Adds the used
commit_rangefor each release.commit_rangeincludes the full length commit ids (commit_range.fromandcommit_range.to) and the short ids (commit_range.from_shortandcommit_range.to_short)Also added related docs (and documentation for the sort_commits default)
Motivation and Context
See #1041
How Has This Been Tested?
Via integration_test and three new fixtures.
Types of Changes
Checklist:
/edit: added a third fixture. no more caveats + documentation and rustfmt/clippy