summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Grunert <mail@saschagrunert.de>2018-08-17 14:23:54 +0200
committerGitHub <noreply@github.com>2018-08-17 14:23:54 +0200
commitec001c87bcf352088f96323757eff43f2151109e (patch)
tree61b4daabbe040aa782646481673e1f6c8524f013
parent3aeaa1d221275796b290cff95d744e09028f331c (diff)
Add tag filter feature (#9)
-rw-r--r--Cargo.lock37
-rw-r--r--Cargo.toml8
-rw-r--r--benches/bench.rs2
-rw-r--r--src/cli.yaml9
-rw-r--r--src/lib.rs37
-rw-r--r--src/main.rs2
6 files changed, 60 insertions, 35 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b345fd9..6349807 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -192,20 +192,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "git-journal"
-version = "1.7.0"
+version = "1.8.0"
dependencies = [
"chrono 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"mowl 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
- "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -241,8 +241,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
-version = "1.0.2"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "libc"
@@ -335,7 +338,7 @@ name = "nom"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -429,7 +432,7 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -480,12 +483,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
-version = "1.0.70"
+version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
-version = "1.0.70"
+version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -551,7 +554,7 @@ name = "thread_local"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -570,7 +573,7 @@ name = "toml"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -635,6 +638,11 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "version_check"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -689,7 +697,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "591f8be1674b421644b6c030969520bc3fa12114d2eb467471982ed3e9584e71"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
-"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3"
+"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff"
"checksum libgit2-sys 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6ab62b46003ba97701554631fa570d9f7e7947e2480ae3d941e555a54a2c0f05"
"checksum libssh2-sys 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c628b499e8d1a4f4bd09a95d6cb1f8aeb231b46a9d40959bbd0408f14dd63adf"
@@ -719,8 +727,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d"
"checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
-"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920"
-"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124"
+"checksum serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb"
+"checksum serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "b719c6d5e9f73fbc37892246d5852333f040caa617b8873c6aced84bcb28e7bb"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44"
"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
@@ -740,6 +748,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
"checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b"
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
+"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
diff --git a/Cargo.toml b/Cargo.toml
index 6ac3a01..18498ed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "git-journal"
-version = "1.7.0"
+version = "1.8.0"
license = "MIT"
readme = "README.md"
keywords = ["parser", "git", "log", "changelog", "journal"]
@@ -23,14 +23,14 @@ chrono = "0.4.5"
clap = { version = "2.32.0", features = ["yaml"] }
failure = "0.1.2"
git2 = "0.7.5"
-lazy_static = "1.0.2"
+lazy_static = "1.1.0"
log = "0.4.3"
mowl = "2.0.0"
nom = { version = "4.0.0", features = ["regexp_macros"] }
rayon = "1.0.2"
regex = "1.0.2"
-serde = "1.0.70"
-serde_derive = "1.0.70"
+serde = "1.0.71"
+serde_derive = "1.0.71"
term = "0.5.1"
toml = "0.4.6"
diff --git a/benches/bench.rs b/benches/bench.rs
index 3bca0e5..037600a 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -18,6 +18,6 @@ fn parse(b: &mut Bencher) {
let mut journal = GitJournal::new(".").unwrap();
journal.config.enable_debug = false;
b.iter(|| {
- journal.parse_log("HEAD", "rc", &0, &true, &false).is_ok();
+ journal.parse_log("HEAD", "rc", &0, &true, &false, None).is_ok();
});
}
diff --git a/src/cli.yaml b/src/cli.yaml
index f697a38..fb2c8a8 100644
--- a/src/cli.yaml
+++ b/src/cli.yaml
@@ -1,3 +1,4 @@
+---
name: git-journal
bin_name: git journal
author: Sascha Grunert <mail@saschagrunert.de>
@@ -43,7 +44,8 @@ args:
long: tags-count
value_name: number of tags
default_value: '1'
- help: The number of tags until the parser stops when a single revision is given.
+ help: The number of tags until the parser stops when a single revision is
+ given.
- tag_skip_pattern:
short: e
value_name: exclude git tag pattern
@@ -59,6 +61,11 @@ args:
long: output
help: The output file for the changelog.
takes_value: true
+ - ignore_tags:
+ short: i
+ long: ignore
+ help: Ignore the given comma separated list of :tags:, like "internal"
+ takes_value: true
subcommands:
- prepare:
diff --git a/src/lib.rs b/src/lib.rs
index 4214afb..9b0b362 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,7 +11,7 @@
//! ```
//! use gitjournal::GitJournal;
//! let mut journal = GitJournal::new(".").unwrap();
-//! journal.parse_log("HEAD", "rc", &1, &false, &true);
+//! journal.parse_log("HEAD", "rc", &1, &false, &true, None);
//! journal.print_log(true, None, None).expect("Could not print short log.");
//! ```
//!
@@ -48,7 +48,7 @@ pub use config::Config;
use failure::Error;
use git2::{ObjectType, Oid, Repository};
use log::LevelFilter;
-use parser::{ParsedTag, Parser, Tags};
+use parser::{ParsedTag, Parser, Print, Tags};
use rayon::prelude::*;
use std::{
collections::BTreeMap,
@@ -399,7 +399,7 @@ impl GitJournal {
/// use gitjournal::GitJournal;
///
/// let mut journal = GitJournal::new(".").unwrap();
- /// journal.parse_log("HEAD", "rc", &1, &false, &false);
+ /// journal.parse_log("HEAD", "rc", &1, &false, &false, None);
/// ```
///
/// # Errors
@@ -413,6 +413,7 @@ impl GitJournal {
max_tags_count: &u32,
all: &bool,
skip_unreleased: &bool,
+ ignore_tags: Option<Vec<&str>>,
) -> Result<(), Error> {
let repo = Repository::open(&self.path)?;
let mut revwalk = repo.revwalk()?;
@@ -510,9 +511,15 @@ impl GitJournal {
.par_iter_mut()
.for_each(|&mut (ref message, ref oid, ref mut result)| {
match self.parser.parse_commit_message(message, Some(*oid)) {
- Ok(parsed_message) => {
- *result = Some(parsed_message);
- }
+ Ok(parsed_message) => match ignore_tags {
+ Some(ref tags) => for tag in tags {
+ // Filter out ignored tags
+ if !parsed_message.contains_tag(Some(tag)) {
+ *result = Some(parsed_message.clone())
+ }
+ },
+ _ => *result = Some(parsed_message),
+ },
Err(e) => warn!("Skipping commit: {}", e),
}
});
@@ -553,7 +560,7 @@ impl GitJournal {
/// use gitjournal::GitJournal;
///
/// let mut journal = GitJournal::new(".").unwrap();
- /// journal.parse_log("HEAD", "rc", &1, &false, &false);
+ /// journal.parse_log("HEAD", "rc", &1, &false, &false, None);
/// journal.generate_template().expect("Template generation failed.");
/// ```
///
@@ -618,7 +625,7 @@ impl GitJournal {
/// use gitjournal::GitJournal;
///
/// let mut journal = GitJournal::new(".").unwrap();
- /// journal.parse_log("HEAD", "rc", &1, &false, &false);
+ /// journal.parse_log("HEAD", "rc", &1, &false, &false, None);
/// journal.print_log(true, None, None).expect("Could not print short log.");
/// journal
/// .print_log(false, None, None)
@@ -778,7 +785,7 @@ mod tests {
assert_eq!(journal.config.colored_output, true);
assert_eq!(journal.config.show_commit_hash, false);
assert_eq!(journal.config.excluded_commit_tags.len(), 0);
- assert!(journal.parse_log("HEAD", "rc", &0, &true, &false).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &0, &true, &false, None).is_ok());
assert_eq!(journal.parser.result.len(), journal.tags.len() + 1);
assert_eq!(journal.parser.result[0].commits.len(), 15);
assert_eq!(journal.parser.result[1].commits.len(), 1);
@@ -800,7 +807,7 @@ mod tests {
#[test]
fn parse_and_print_log_2() {
let mut journal = GitJournal::new("./tests/test_repo").unwrap();
- assert!(journal.parse_log("HEAD", "rc", &1, &false, &false).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &1, &false, &false, None).is_ok());
assert_eq!(journal.parser.result.len(), 2);
assert_eq!(journal.parser.result[0].name, "Unreleased");
assert_eq!(journal.parser.result[1].name, "v2");
@@ -821,7 +828,7 @@ mod tests {
#[test]
fn parse_and_print_log_3() {
let mut journal = GitJournal::new("./tests/test_repo").unwrap();
- assert!(journal.parse_log("HEAD", "rc", &1, &false, &true).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &1, &false, &true, None).is_ok());
assert_eq!(journal.parser.result.len(), 1);
assert_eq!(journal.parser.result[0].name, "v2");
assert!(journal.print_log(false, None, Some("CHANGELOG.md")).is_ok());
@@ -841,7 +848,7 @@ mod tests {
#[test]
fn parse_and_print_log_4() {
let mut journal = GitJournal::new("./tests/test_repo").unwrap();
- assert!(journal.parse_log("HEAD", "rc", &2, &false, &true).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &2, &false, &true, None).is_ok());
assert_eq!(journal.parser.result.len(), 2);
assert_eq!(journal.parser.result[0].name, "v2");
assert_eq!(journal.parser.result[1].name, "v1");
@@ -862,7 +869,7 @@ mod tests {
#[test]
fn parse_and_print_log_5() {
let mut journal = GitJournal::new("./tests/test_repo").unwrap();
- assert!(journal.parse_log("v1..v2", "rc", &0, &true, &false).is_ok());
+ assert!(journal.parse_log("v1..v2", "rc", &0, &true, &false, None).is_ok());
assert_eq!(journal.parser.result.len(), 1);
assert_eq!(journal.parser.result[0].name, "v2");
assert!(journal.print_log(false, None, Some("CHANGELOG.md")).is_ok());
@@ -882,7 +889,7 @@ mod tests {
#[test]
fn parse_and_print_log_6() {
let mut journal = GitJournal::new("./tests/test_repo2").unwrap();
- assert!(journal.parse_log("HEAD", "rc", &0, &true, &false).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &0, &true, &false, None).is_ok());
assert!(journal.print_log(false, None, Some("CHANGELOG.md")).is_ok());
}
@@ -939,7 +946,7 @@ mod tests {
fn generate_template_1() {
let mut journal = GitJournal::new("./tests/test_repo").unwrap();
assert!(journal.generate_template().is_ok());
- assert!(journal.parse_log("HEAD", "rc", &0, &true, &false).is_ok());
+ assert!(journal.parse_log("HEAD", "rc", &0, &true, &false, None).is_ok());
assert!(journal.generate_template().is_ok());
}
diff --git a/src/main.rs b/src/main.rs
index 6a37b90..dece983 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,6 +96,7 @@ fn main() -> Result<(), Error> {
.value_of("tags_count")
.ok_or_else(|| format_err!("No CLI 'tags_count' provided"))?;
let max_tags = tags_count.parse::<u32>()?;
+ let ignore_tags: Option<Vec<&str>> = matches.value_of("ignore_tags").map(|s| s.split(",").collect());
// Parse the log
if let Err(error) = journal.parse_log(
@@ -104,6 +105,7 @@ fn main() -> Result<(), Error> {
&max_tags,
&matches.is_present("all"),
&matches.is_present("skip_unreleased"),
+ ignore_tags,
) {
bail!("Log parsing error {}", &error);
}