diff --git a/Cargo.lock b/Cargo.lock index 52fe182e..1f7d5103 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -610,9 +610,9 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git-cliff-core" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814781ddaef452cc690361d408ce56dfbab6a522d3065cc49329732cde69e783" +checksum = "3b82ecf763c4f7f9564880776ec536417e3ecd7c7d773f1413091c42afcdf265" dependencies = [ "bincode", "cacache", @@ -1423,9 +1423,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.10" +version = "2.16.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04409e8c2d61995696e44d2181b79b68c1dd41f7e24a17cde60bbd9f54ddddef" +checksum = "53575dfa17f208dd1ce3a2da2da4659aae393b256a472f2738a8586a6c4107fd" dependencies = [ "bitflags", "ctor", @@ -2814,7 +2814,7 @@ dependencies = [ [[package]] name = "workspace-node-tools" -version = "2.0.1" +version = "2.0.2" dependencies = [ "chrono", "execute", diff --git a/Cargo.toml b/Cargo.toml index 8fcf10d0..af181e06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "workspace-node-tools" -version = "2.0.1" +version = "2.0.2" edition = "2021" description = "Node workspace version tools" repository = "https://github.com/websublime/workspace-node-tools" @@ -19,14 +19,14 @@ serde_json = "1.0.128" regex = "1.10.6" wax = { version = "0.6.0", features = ["walk"] } napi-derive = { version = "2.16.12", optional = true } -napi = { version = "2.16.10", default-features = false, features = [ +napi = { version = "2.16.11", default-features = false, features = [ "napi9", "serde-json", "tokio_rt", ], optional = true } icu = "1.5.0" version-compare = "0.2" -git-cliff-core = "2.5.0" +git-cliff-core = "2.6.0" chrono = "0.4.38" semver = "1.0.23" rand = "0.8.5" diff --git a/src/conventional.rs b/src/conventional.rs index ca010ee9..e0e8cf7a 100644 --- a/src/conventional.rs +++ b/src/conventional.rs @@ -63,6 +63,22 @@ pub struct ConventionalPackageOptions { fn process_commits<'a>(commits: &Vec, config: &GitConfig) -> Vec> { commits .iter() + .filter(|commit| { + let timestamp = chrono::DateTime::parse_from_rfc2822(&commit.author_date).unwrap(); + + let git_commit = GitCommit { + id: commit.hash.to_string(), + message: commit.message.to_string(), + author: Signature { + name: Some(commit.author_name.to_string()), + email: Some(commit.author_email.to_string()), + timestamp: timestamp.timestamp(), + }, + ..GitCommit::default() + }; + + git_commit.into_conventional().is_ok() + }) .map(|commit| { let timestamp = chrono::DateTime::parse_from_rfc2822(&commit.author_date).unwrap(); @@ -154,84 +170,74 @@ fn define_config( replace: Some(String::from(github_url)), replace_command: None, }]), + render_always: Some(false), + ..ChangelogConfig::default() }, git: GitConfig { commit_parsers: Some(vec![ CommitParser { - message: Some(Regex::new("^feat").expect("failed to compile regex")), + message: Regex::new("^feat").ok(), group: Some(String::from("โ›ฐ๏ธ Features")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^fix").expect("failed to compile regex")), + message: Regex::new("^fix").ok(), group: Some(String::from("๐Ÿ› Bug Fixes")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^doc").expect("failed to compile regex")), + message: Regex::new("^doc").ok(), group: Some(String::from("๐Ÿ“š Documentation")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^perf").expect("failed to compile regex")), + message: Regex::new("^perf").ok(), group: Some(String::from("โšก Performance")), ..CommitParser::default() }, CommitParser { - message: Some( - Regex::new("^refactor\\(clippy\\)") - .expect("failed to compile regex"), - ), + message: Regex::new("^refactor\\(clippy\\)").ok(), skip: Some(true), ..CommitParser::default() }, CommitParser { - message: Some( - Regex::new("^refactor").expect("failed to compile regex"), - ), + message: Regex::new("^refactor").ok(), group: Some(String::from("๐Ÿšœ Refactor")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^style").expect("failed to compile regex")), + message: Regex::new("^style").ok(), group: Some(String::from("๐ŸŽจ Styling")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^test").expect("failed to compile regex")), + message: Regex::new("^test").ok(), group: Some(String::from("๐Ÿงช Testing")), ..CommitParser::default() }, CommitParser { - message: Some( - Regex::new("^chore|^ci").expect("failed to compile regex"), - ), + message: Regex::new("^chore|^ci").ok(), group: Some(String::from("โš™๏ธ Miscellaneous Tasks")), ..CommitParser::default() }, CommitParser { - body: Some(Regex::new(".*security").expect("failed to compile regex")), + body: Regex::new(".*security").ok(), group: Some(String::from("๐Ÿ›ก๏ธ Security")), ..CommitParser::default() }, CommitParser { - message: Some(Regex::new("^revert").expect("failed to compile regex")), + message: Regex::new("^revert").ok(), group: Some(String::from("โ—€๏ธ Revert")), ..CommitParser::default() }, ]), protect_breaking_commits: Some(false), filter_commits: Some(false), - tag_pattern: Some( - Regex::new("^((?:@[^/@]+/)?[^/@]+)(?:@([^/]+))?$") - .expect("failed to compile regex"), - ), - skip_tags: Some( - Regex::new("beta|alpha|snapshot").expect("failed to compile regex"), - ), - ignore_tags: Some( - Regex::new("rc|beta|alpha|snapshot").expect("failed to compile regex"), - ), + filter_unconventional: Some(true), + conventional_commits: Some(true), + tag_pattern: Regex::new("^((?:@[^/@]+/)?[^/@]+)(?:@([^/]+))?$").ok(), + skip_tags: Regex::new("beta|alpha|snapshot").ok(), + ignore_tags: Regex::new("rc|beta|alpha|snapshot").ok(), topo_order: Some(false), sort_commits: Some(String::from("newest")), ..GitConfig::default()