Skip to content

Commit

Permalink
🐛 Use 0.0.0 as default tag if there are no tags in the repository
Browse files Browse the repository at this point in the history
semver: patch
  • Loading branch information
Somfic committed Jun 7, 2024
1 parent 608d094 commit ec1df00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/git/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub fn patches_since(tag: &String) -> Result<Vec<Commit>> {
}

fn since(tag: &String, grep: &str) -> Result<Vec<Commit>> {
let since = if tag == "0.0.0" {
"".to_string()
} else {
format!("{}..HEAD", tag).to_string()
};

Ok(execute(
"git",
vec![
Expand All @@ -57,7 +63,7 @@ fn since(tag: &String, grep: &str) -> Result<Vec<Commit>> {
"--all",
"--decorate=short",
"--pretty=format:%s",
&format!("{}..HEAD", tag),
since.as_str(),
],
)?
.lines()
Expand Down
3 changes: 2 additions & 1 deletion src/git/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use crate::cmd::execute;
pub fn latest() -> anyhow::Result<String> {
execute("git", vec!["fetch", "--tags"])?;

let result = execute("git", vec!["describe", "--tags", "--abbrev=0"])?;
let result =
execute("git", vec!["describe", "--tags", "--abbrev=0"]).unwrap_or("0.0.0".to_owned());

Ok(result.trim().to_string())
}
Expand Down

0 comments on commit ec1df00

Please sign in to comment.