From ec1df00b8b8c0ed2f17f22797cd11b69cd9f1240 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 8 Jun 2024 01:07:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=200.0.0=20as=20default=20tag?= =?UTF-8?q?=20if=20there=20are=20no=20tags=20in=20the=20repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit semver: patch --- src/git/log.rs | 8 +++++++- src/git/tag.rs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/git/log.rs b/src/git/log.rs index 57d2bd9..faa2574 100644 --- a/src/git/log.rs +++ b/src/git/log.rs @@ -48,6 +48,12 @@ pub fn patches_since(tag: &String) -> Result> { } fn since(tag: &String, grep: &str) -> Result> { + let since = if tag == "0.0.0" { + "".to_string() + } else { + format!("{}..HEAD", tag).to_string() + }; + Ok(execute( "git", vec![ @@ -57,7 +63,7 @@ fn since(tag: &String, grep: &str) -> Result> { "--all", "--decorate=short", "--pretty=format:%s", - &format!("{}..HEAD", tag), + since.as_str(), ], )? .lines() diff --git a/src/git/tag.rs b/src/git/tag.rs index d9411b7..3c41938 100644 --- a/src/git/tag.rs +++ b/src/git/tag.rs @@ -3,7 +3,8 @@ use crate::cmd::execute; pub fn latest() -> anyhow::Result { 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()) }