-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat(next_version): support configuration #1168
feat(next_version): support configuration #1168
Conversation
I would prefer a non-breaking change. Let's keep the default behavior as it is. |
Added tests. |
struct VersionUpdater {
pub uncontrolled_minor_bump: bool,
pub initial_major_increment: bool,
}
impl VersionUpdater {
// builder lite pattern https://matklad.github.io/2022/05/29/builder-lite.html
fn with_uncontrolled_minor_bump(mut self, uncontrolled_minor_bump) -> Self { self.uncontrolled_minor_bump = uncontrolled_minor_bump; self }
fn next(&self, version: Version, commits: I) -> Version { }
} Then Version::next calls VersionUpdater with the default options. |
I didn't get it, do you wanna define another struct called |
yes
Let's delete it. The VersionUpdater has the default configuration, which you can override with the builder pattern. |
Sorry, I'm not following. Do you want to achieve the following API? let next_version = semver
.next(
vec![]
)
.with_uncontrolled_minor_bump(true)
.with_initial_major_increment(true)
.to_string(); |
Or is it something like this? VersionUpdater::new(semver)
.with_uncontrolled_minor_bump(true)
.with_initial_major_increment(true)
.next(vec![]) |
VersionUpdater::new()
.with_uncontrolled_minor_bump(true)
.with_initial_major_increment(true)
.next(semver, vec![]) I was thinking this what do you think? |
Sure, makes sense. Implemented in d3d3fb0 |
This PR makes it possible to configure the
next_version
crate to customize the behavior for cases like orhun/git-cliff#343e.g.:
A couple of points:
config
parameter to thenext
function. Let me know if you are fine with it or not and we can probably think of a way to make it non-breaking. I think it is fine though.git-cliff
directly and it seems to work as expected. However, I must say it was really hard to wrap my head around the conditions so I might have missed something. Please double check.🐻