Skip to content

Commit

Permalink
Merge pull request #41 from thoughtram/issue-5
Browse files Browse the repository at this point in the history
Implements #5
  • Loading branch information
cburgdorf committed May 23, 2015
2 parents 1fc9654 + a339e6d commit ace4b46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 ace4b46

Please sign in to comment.