Skip to content

Commit c5c0276

Browse files
committed
feat(version headers): distinguishes between minor and patch version headers
Patch versions use "###" headers and everything else uses "##" Closes #5
1 parent 1fc9654 commit c5c0276

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/clogconfig.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct ClogConfig {
1717
pub format: String,
1818
pub repo: String,
1919
pub version: String,
20+
pub patch_ver: bool,
2021
pub subtitle: String,
2122
pub from: String,
2223
pub to: String,
@@ -29,6 +30,7 @@ pub type ConfigResult = Result<ClogConfig, Box<Display>>;
2930
impl ClogConfig {
3031
pub fn from_matches(matches: &ArgMatches) -> ConfigResult {
3132
// compute version early, so we can exit on error
33+
let mut patch_ver = false;
3234
let version = {
3335
// less typing later...
3436
let (major, minor, patch) = (matches.is_present("major"), matches.is_present("minor"), matches.is_present("patch"));
@@ -50,7 +52,7 @@ impl ClogConfig {
5052
match (major, minor, patch) {
5153
(true,_,_) => { v.major += 1; v.minor = 0; v.patch = 0; },
5254
(_,true,_) => { v.minor += 1; v.patch = 0; },
53-
(_,_,true) => { v.patch += 1; },
55+
(_,_,true) => { v.patch += 1; patch_ver = true; },
5456
_ => unreachable!()
5557
}
5658
format!("{}{}", if had_v{"v"}else{""}, v)
@@ -173,6 +175,7 @@ impl ClogConfig {
173175
format: "%H%n%s%n%b%n==END==".to_owned(),
174176
repo: repo,
175177
version: version,
178+
patch_ver: patch_ver,
176179
subtitle: subtitle,
177180
from: from,
178181
to: matches.value_of("to").unwrap_or("HEAD").to_owned(),

src/log_writer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ impl<'a, 'cc> LogWriter<'a, 'cc> {
3434
_ => format!(" {}", self.options.subtitle)
3535
};
3636

37-
let version_text = format!("## {}{}", self.options.version, subtitle);
37+
let version_text = if self.options.patch_ver {
38+
format!("### {}{}", self.options.version, subtitle)
39+
} else {
40+
format!("## {}{}", self.options.version, subtitle)
41+
};
3842

3943
let date = time::now_utc();
4044

0 commit comments

Comments
 (0)