Skip to content

Commit

Permalink
feat(version headers): distinguishes between minor and patch version …
Browse files Browse the repository at this point in the history
…headers

Patch versions use "###" headers and everything else uses "##"

Closes #5
  • Loading branch information
kbknapp committed May 23, 2015
1 parent 1fc9654 commit c5c0276
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/clogconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -29,6 +30,7 @@ pub type ConfigResult = Result<ClogConfig, Box<Display>>;
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"));
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 5 additions & 1 deletion src/log_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit c5c0276

Please sign in to comment.