mirror of
https://github.com/orhun/git-cliff.git
synced 2024-12-02 01:24:06 +03:00
fix(changelog): return the last version if there is nothing to bump
fixes #533
This commit is contained in:
parent
d0c9d3b97f
commit
45c87f2f30
@ -24,7 +24,8 @@ use std::time::{
|
||||
/// Changelog generator.
|
||||
#[derive(Debug)]
|
||||
pub struct Changelog<'a> {
|
||||
releases: Vec<Release<'a>>,
|
||||
/// Releases that the changelog will contain.
|
||||
pub releases: Vec<Release<'a>>,
|
||||
body_template: Template,
|
||||
footer_template: Option<Template>,
|
||||
config: &'a Config,
|
||||
|
@ -464,16 +464,28 @@ pub fn run(mut args: Opt) -> Result<()> {
|
||||
|
||||
// Print the result.
|
||||
if args.bump || args.bumped_version {
|
||||
if let Some(next_version) = changelog.bump_version()? {
|
||||
if args.bumped_version {
|
||||
if let Some(path) = args.output {
|
||||
let mut output = File::create(path)?;
|
||||
output.write_all(next_version.as_bytes())?;
|
||||
} else {
|
||||
println!("{next_version}");
|
||||
}
|
||||
return Ok(());
|
||||
let next_version = if let Some(next_version) = changelog.bump_version()? {
|
||||
next_version
|
||||
} else if let Some(last_version) = changelog
|
||||
.releases
|
||||
.iter()
|
||||
.next()
|
||||
.cloned()
|
||||
.and_then(|v| v.version)
|
||||
{
|
||||
warn!("There is nothing to bump.");
|
||||
last_version
|
||||
} else {
|
||||
return Ok(());
|
||||
};
|
||||
if args.bumped_version {
|
||||
if let Some(path) = args.output {
|
||||
let mut output = File::create(path)?;
|
||||
output.write_all(next_version.as_bytes())?;
|
||||
} else {
|
||||
println!("{next_version}");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
if args.context {
|
||||
|
Loading…
Reference in New Issue
Block a user