diff options
author | Sascha Grunert <Sascha.Grunert@rohde-schwarz.com> | 2016-09-23 08:24:53 +0200 |
---|---|---|
committer | Sascha Grunert <Sascha.Grunert@rohde-schwarz.com> | 2016-09-23 08:24:53 +0200 |
commit | c6ee7bf36a977fc15493318c78a9ff1ab0b50c2c (patch) | |
tree | 3aca473a01356e43000cce6839eea7eade4eeeba | |
parent | f84bc7ecacc4330782d1aa03bd5bd236299b345d (diff) |
Improved documentation of default values0.4.0
-rw-r--r-- | src/lib.rs | 14 | ||||
-rw-r--r-- | src/parser.rs | 25 |
2 files changed, 19 insertions, 20 deletions
@@ -207,7 +207,7 @@ impl GitJournal { /// like: /// /// ```toml - /// # Specifies the available categories for the commit message + /// # Specifies the available categories for the commit message, allowd regular expressions. /// categories = ["Added", "Changed", "Fixed", "Improved", "Removed"] /// /// # Set to false if the output should not be colored @@ -223,13 +223,13 @@ impl GitJournal { /// # Excluded tags in an array, e.g. "internal" /// excluded_commit_tags = [] /// - /// Enable or disable the output and accumulation of commit footers + /// Enable or disable the output and accumulation of commit footers. /// pub enable_footers: bool, /// /// # Show or hide the commit message prefix, e.g. JIRA-1234 /// show_prefix = false /// - /// # Commit message template prefix which will be added during commit preparation + /// # Commit message template prefix which will be added during commit preparation. /// template_prefix = "JIRA-1234" /// ``` /// @@ -416,7 +416,7 @@ impl GitJournal { } // Iterate over the git objects and collect them in a vector of tuples - let mut parsed_tags: u32 = 1; + let mut num_parsed_tags: u32 = 1; let unreleased_str = "Unreleased"; let mut current_tag = ParsedTag { name: unreleased_str.to_owned(), @@ -437,12 +437,12 @@ impl GitJournal { } // If a single revision is given stop at the first seen tag - if !all && index > 0 && parsed_tags > *max_tags_count { + if !all && index > 0 && num_parsed_tags > *max_tags_count { break 'revloop; } // Format the tag and set as current - parsed_tags += 1; + num_parsed_tags += 1; let date = UTC.timestamp(commit.time().seconds(), 0).date(); current_tag = ParsedTag { name: tag.1.clone(), @@ -526,7 +526,7 @@ impl GitJournal { }; // Print the log - let output_vec = try!(self.parser.print(&self.parser.result, &self.config, &compact, used_template)); + let output_vec = try!(self.parser.print(&self.config, &compact, used_template)); // Print the log to the file if necessary if let Some(output) = output { diff --git a/src/parser.rs b/src/parser.rs index e877294..b7694f3 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -14,10 +14,10 @@ use std::str; use config::Config; -static DEFAULT_TAG: &'static str = "default"; -static FOOTER_TAG: &'static str = "footers"; -static NAME_TAG: &'static str = "name"; -static TAG: &'static str = "tag"; +static TOML_DEFAULT_KEY: &'static str = "default"; +static TOML_FOOTER_KEY: &'static str = "footers"; +static TOML_NAME_KEY: &'static str = "name"; +static TOML_TAG: &'static str = "tag"; #[derive(Debug)] pub enum Error { @@ -116,7 +116,7 @@ pub trait Print { fn matches_default_tag(&self, tag: Option<&str>) -> bool { match tag { - Some(tag) => tag == DEFAULT_TAG && self.contains_untagged_elements(), + Some(tag) => tag == TOML_DEFAULT_KEY && self.contains_untagged_elements(), None => false, } } @@ -251,11 +251,11 @@ impl ParsedTag { } let header_lvl: String = iter::repeat('#').take(*level).collect(); - let tag = match table.get(TAG) { + let tag = match table.get(TOML_TAG) { Some(t) => t.as_str().unwrap_or(""), None => return Ok(()), }; - let name = match table.get(NAME_TAG) { + let name = match table.get(TOML_NAME_KEY) { Some(name_value) => name_value.as_str().unwrap_or(tag), None => tag, }; @@ -263,12 +263,12 @@ impl ParsedTag { if (*compact && ((self.commits.iter().filter(|c| c.summary.contains_tag(Some(tag))).count() > 0 && !config.excluded_commit_tags.contains(&tag.to_owned())) || - (tag == DEFAULT_TAG && + (tag == TOML_DEFAULT_KEY && self.commits.iter().filter(|c| c.summary.contains_untagged_elements()).count() > 0))) || (!*compact && ((self.commits.iter().filter(|c| c.contains_tag(Some(tag))).count() > 0 && !config.excluded_commit_tags.contains(&tag.to_owned())) || - (tag == DEFAULT_TAG && self.commits.iter().filter(|c| c.contains_untagged_elements()).count() > 0))) { + (tag == TOML_DEFAULT_KEY && self.commits.iter().filter(|c| c.contains_untagged_elements()).count() > 0))) { if config.colored_output { @@ -294,7 +294,7 @@ impl ParsedTag { } // Print footers is specified in template - if let Some(footers) = table.get(FOOTER_TAG) { + if let Some(footers) = table.get(TOML_FOOTER_KEY) { if let toml::Value::Array(ref array) = *footers { try!(self.print_footers(term, vec, Some(array), config)); } @@ -656,7 +656,7 @@ impl Parser { chain!( tag!("[")? ~ p_category: map_res!( - re_bytes_find!(&self.categories.join("|")), // TODO: this is slow + re_bytes_find!(&self.categories.join("|")), str::from_utf8 ) ~ tag!("]")? , @@ -774,7 +774,6 @@ impl Parser { /// Prints the commits without any template pub fn print(&self, - parsed_tags: &[ParsedTag], config: &Config, compact: &bool, template: Option<&str>) @@ -783,7 +782,7 @@ impl Parser { let mut term = try!(term::stdout().ok_or(Error::Terminal)); let mut vec = vec![]; - for tag in parsed_tags { + for tag in &self.result { try!(tag.print_to_term_and_write_to_vector(&mut term, &mut vec, compact, config, template)); } |