1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-11-29 13:23:40 +03:00

fix(changelog): allow using --bumped-version without conventional commits (#806)

This commit is contained in:
Orhun Parmaksız 2024-08-22 09:11:39 +03:00 committed by GitHub
parent 6f8ea19baa
commit e74080cec4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 13 deletions

View File

@ -14,6 +14,9 @@ use std::fs;
use std::path::Path;
use std::path::PathBuf;
/// Default initial tag.
const DEFAULT_INITIAL_TAG: &str = "0.1.0";
/// Manifest file information and regex for matching contents.
#[derive(Debug)]
struct ManifestInfo {
@ -246,6 +249,30 @@ pub struct Bump {
pub bump_type: Option<BumpType>,
}
impl Bump {
/// Returns the initial tag.
///
/// This function also logs the returned value.
pub fn get_initial_tag(&self) -> String {
match self.initial_tag.clone() {
Some(tag) => {
warn!(
"No releases found, using initial tag '{tag}' as the next \
version."
);
tag
}
None => {
warn!(
"No releases found, using {DEFAULT_INITIAL_TAG} as the next \
version."
);
DEFAULT_INITIAL_TAG.into()
}
}
}
}
/// Parser for grouping commits.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct CommitParser {

View File

@ -154,19 +154,7 @@ impl<'a> Release<'a> {
Ok(next_version)
}
}
None => match config.initial_tag.clone() {
Some(tag) => {
warn!(
"No releases found, using initial tag '{tag}' as the next \
version."
);
Ok(tag)
}
None => {
warn!("No releases found, using 0.1.0 as the next version.");
Ok(String::from("0.1.0"))
}
},
None => Ok(config.get_initial_tag()),
}
}
}

View File

@ -583,6 +583,8 @@ pub fn run(mut args: Opt) -> Result<()> {
{
warn!("There is nothing to bump.");
last_version
} else if changelog.releases.is_empty() {
config.bump.get_initial_tag()
} else {
return Ok(());
};