diff --git a/Cargo.lock b/Cargo.lock index 9bdc324..86068cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ name = "clog" version = "0.6.0" dependencies = [ - "clap 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "regex_macros 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -17,7 +17,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "0.9.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/clogconfig.rs b/src/clogconfig.rs index 41af2ea..2d445f2 100644 --- a/src/clogconfig.rs +++ b/src/clogconfig.rs @@ -17,6 +17,7 @@ pub struct ClogConfig { pub format: String, pub repo: String, pub version: String, + pub patch_ver: bool, pub subtitle: String, pub from: String, pub to: String, @@ -29,6 +30,7 @@ pub type ConfigResult = Result>; impl ClogConfig { pub fn from_matches(matches: &ArgMatches) -> ConfigResult { // compute version early, so we can exit on error + let mut patch_ver = false; let version = { // less typing later... let (major, minor, patch) = (matches.is_present("major"), matches.is_present("minor"), matches.is_present("patch")); @@ -50,7 +52,7 @@ impl ClogConfig { match (major, minor, patch) { (true,_,_) => { v.major += 1; v.minor = 0; v.patch = 0; }, (_,true,_) => { v.minor += 1; v.patch = 0; }, - (_,_,true) => { v.patch += 1; }, + (_,_,true) => { v.patch += 1; patch_ver = true; }, _ => unreachable!() } format!("{}{}", if had_v{"v"}else{""}, v) @@ -173,6 +175,7 @@ impl ClogConfig { format: "%H%n%s%n%b%n==END==".to_owned(), repo: repo, version: version, + patch_ver: patch_ver, subtitle: subtitle, from: from, to: matches.value_of("to").unwrap_or("HEAD").to_owned(), diff --git a/src/log_writer.rs b/src/log_writer.rs index c6de0af..be9da76 100644 --- a/src/log_writer.rs +++ b/src/log_writer.rs @@ -34,7 +34,11 @@ impl<'a, 'cc> LogWriter<'a, 'cc> { _ => format!(" {}", self.options.subtitle) }; - let version_text = format!("## {}{}", self.options.version, subtitle); + let version_text = if self.options.patch_ver { + format!("### {}{}", self.options.version, subtitle) + } else { + format!("## {}{}", self.options.version, subtitle) + }; let date = time::now_utc();