mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-29 15:42:15 +03:00
feat(args): accept glob patterns for --commit-path
argument
This commit is contained in:
parent
6cec37d1ec
commit
ad11cbf6c5
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -356,6 +356,7 @@ dependencies = [
|
||||
"config",
|
||||
"git-conventional",
|
||||
"git2",
|
||||
"glob",
|
||||
"indexmap",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
@ -393,6 +394,12 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.8"
|
||||
|
@ -207,7 +207,7 @@ git cliff HEAD~2..
|
||||
Generate a changelog scoped to a specific directory (useful for monorepos):
|
||||
|
||||
```sh
|
||||
git cliff --commit-path project1/
|
||||
git cliff --commit-path '**/*.toml'
|
||||
```
|
||||
|
||||
Sort the commits inside sections:
|
||||
|
@ -18,6 +18,7 @@ regex = "1.5.4"
|
||||
serde_regex = "1.1.0"
|
||||
indexmap = "1.7.0"
|
||||
toml = "0.5.8"
|
||||
glob = "0.3.0"
|
||||
|
||||
[dependencies.git2]
|
||||
version = "0.13.23"
|
||||
|
@ -1,8 +1,11 @@
|
||||
//! A highly customizable changelog generator
|
||||
#![warn(missing_docs, clippy::unwrap_used)]
|
||||
|
||||
/// Export regex crate.
|
||||
/// Export `glob` crate.
|
||||
pub use glob;
|
||||
/// Export `regex` crate.
|
||||
pub use regex;
|
||||
|
||||
/// Git commit.
|
||||
pub mod commit;
|
||||
/// Config file parser.
|
||||
|
@ -7,6 +7,7 @@ use git2::{
|
||||
Repository as GitRepository,
|
||||
Sort,
|
||||
};
|
||||
use glob::Pattern;
|
||||
use indexmap::IndexMap;
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
@ -39,7 +40,7 @@ impl Repository {
|
||||
pub fn commits(
|
||||
&self,
|
||||
range: Option<String>,
|
||||
path: Option<String>,
|
||||
path: Option<Pattern>,
|
||||
) -> Result<Vec<Commit>> {
|
||||
let mut revwalk = self.inner.revwalk()?;
|
||||
revwalk.set_sorting(Sort::TIME | Sort::TOPOLOGICAL)?;
|
||||
@ -64,7 +65,7 @@ impl Repository {
|
||||
) {
|
||||
return diff.deltas().any(|delta| {
|
||||
delta.new_file().path().map_or(false, |path| {
|
||||
path.starts_with(&commit_path)
|
||||
commit_path.matches_path(path)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use git_cliff_core::glob::Pattern;
|
||||
use git_cliff_core::DEFAULT_CONFIG;
|
||||
use std::path::PathBuf;
|
||||
use structopt::clap::AppSettings;
|
||||
@ -38,7 +39,7 @@ pub struct Opt {
|
||||
pub repository: Option<PathBuf>,
|
||||
/// Sets the directory to parse commits from.
|
||||
#[structopt(long, env, value_name = "PATH")]
|
||||
pub commit_path: Option<String>,
|
||||
pub commit_path: Option<Pattern>,
|
||||
/// Prepends entries to the given changelog file.
|
||||
#[structopt(short, long, env, value_name = "PATH")]
|
||||
pub prepend: Option<PathBuf>,
|
||||
|
Loading…
Reference in New Issue
Block a user