-
-
Notifications
You must be signed in to change notification settings - Fork 213
Add commit_range to template context #1041
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
Comments
Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️ |
Good idea! We simply need to add Marking this as good-first-issue, would you be interested in contributing? |
i'll try to make some time next week and have a look. |
Perfect, assigned to you! Let me know if you need any assistance. |
Hey, i finally could make the time to have a look. Unless i'm overlooking something this might not be as straight forward as thought. Here are my observations: Currently the commit range is passed when getting the commits for changelog creation, we don't have ownership of the repo there. //...
let first_commit = commits.first().unwrap().id();
let last_commit = commits.last().unwrap().id();
let commit_range =
CommitRange::new(&first_commit.to_string(), &last_commit.to_string());
for git_commit in commits.iter().rev() {
let release = releases.last_mut().unwrap();
//..
release.commit_range = Some(commit_range.clone());
// ... with /// Commit range (from..to)
pub struct CommitRange {
from: String,
to: String,
} From what i could tell this is currently not easily testable though, right? Let me know your thoughts. |
Can you elaborate on the use case for this request? Do you want to generate a diff between a change's commit and the previous release? |
I think yes... I cannot think of another use case.
Hmm yeah, good point.
Yup, that looks good to me. I think that would be the most correct way of getting the range.
Can you elaborate this a bit? What do you want to do exactly? |
yes, as stated:
in my case this would be achieveable via the commit hashes
my proposal would put the logic in |
I think we can use test fixtures for testing this functionality in the first phase. And yes, I think |
Ah, missed those. It looks like commits are created "on the fly" there. Any quick idea how i can deterministically create the same commit sha every time? Apply patches? I'll try to get a pr going some time soon. |
Good question. I think applying patches might work. Or we can install a tool like Edit: Just do this in #!/usr/bin/env bash
set -e
git remote add origin https://github.com/orhun/git-cliff-readme-example
git pull origin master
git fetch --tags |
still on my list, just didn't get to it yet. apologies for the delay |
no worries :) |
Hey, i found the time to work a bit on this. I feel it's still a bit more complicated than thought :D While playing around with it, i figured that you don't necessarily want the whole commit id but the short id, especially for display purposes. So i added a You can see the current state here (no docs yet etc.) Running that on the
Generates the following:
So far so good. This seems to work. Problematic is, that there's also other ways to create a commit. Either from a String or from id and message String. The latter seems to only be used in test cases, which should be unproblematic. The former get's used in case of custom commits though. What do you think is the best option here? I also could not figure out how to run this integration_test. Is that in use somewhere? /edit: correct template output |
Hey again, thanks for the PoC! Seems fine to me, please send a PR!
I guess that's fine - it's a tradeoff when custom commits are used.
Can you elaborate this? Are you trying to update that test to include coverage for this feature.I think it should be run when you do |
nvm this. I got something mixed up. |
Hey,
i would like to add links to diffs of certain files to the changelog.
Is there a way to get the commit range git cliff uses or was called with (in my case
git cliff commitA..commitB
)? As far as i could see it's not part of the context.Thanks
The text was updated successfully, but these errors were encountered: