Skip to content

Commit

Permalink
feat(args): support multiple values for --commit-path argument
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Nov 30, 2021
1 parent ad11cbf commit edb343a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ git-cliff [FLAGS] [OPTIONS] [RANGE]
**Options:**

```
-c, --config <PATH> Sets the configuration file [env: CONFIG=] [default: cliff.toml]
-w, --workdir <PATH> Sets the working directory [env: WORKDIR=]
-r, --repository <PATH> Sets the git repository [env: REPOSITORY=]
--commit-path <PATH> Sets the directory to parse commits from [env: COMMIT_PATH=]
-p, --prepend <PATH> Prepends entries to the given changelog file [env: PREPEND=]
-o, --output <PATH> Writes output to the given file [env: OUTPUT=]
-t, --tag <TAG> Sets the tag for the latest version [env: TAG=]
-b, --body <TEMPLATE> Sets the template for the changelog body [env: TEMPLATE=]
-s, --strip <PART> Strips the given parts from the changelog [possible values: header, footer, all]
--sort <sort> Sets sorting of the commits inside sections [default: oldest] [possible values: oldest, newest]
-c, --config <PATH> Sets the configuration file [env: CONFIG=] [default: cliff.toml]
-w, --workdir <PATH> Sets the working directory [env: WORKDIR=]
-r, --repository <PATH> Sets the git repository [env: REPOSITORY=]
--commit-path <PATTERN>... Sets the directory to parse commits from [env: COMMIT_PATH=]
-p, --prepend <PATH> Prepends entries to the given changelog file [env: PREPEND=
-o, --output <PATH> Writes output to the given file [env: OUTPUT=]
-t, --tag <TAG> Sets the tag for the latest version [env: TAG=]
-b, --body <TEMPLATE> Sets the template for the changelog body [env: TEMPLATE=]
-s, --strip <PART> Strips the given parts from the changelog [possible values: header, footer, all]
--sort <sort> Sets sorting of the commits inside sections [default: oldest] [possible values: oldest, newest]
```

**Args:**
Expand Down Expand Up @@ -207,7 +207,7 @@ git cliff HEAD~2..
Generate a changelog scoped to a specific directory (useful for monorepos):

```sh
git cliff --commit-path '**/*.toml'
git cliff --commit-path "**/*.toml" --commit-path "*.md"
```

Sort the commits inside sections:
Expand Down
6 changes: 4 additions & 2 deletions git-cliff-core/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Repository {
pub fn commits(
&self,
range: Option<String>,
path: Option<Pattern>,
path: Option<Vec<Pattern>>,
) -> Result<Vec<Commit>> {
let mut revwalk = self.inner.revwalk()?;
revwalk.set_sorting(Sort::TIME | Sort::TOPOLOGICAL)?;
Expand All @@ -65,7 +65,9 @@ impl Repository {
) {
return diff.deltas().any(|delta| {
delta.new_file().path().map_or(false, |path| {
commit_path.matches_path(path)
commit_path
.iter()
.any(|glob| glob.matches_path(path))
})
});
}
Expand Down
4 changes: 2 additions & 2 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub struct Opt {
#[structopt(short, long, env, value_name = "PATH")]
pub repository: Option<PathBuf>,
/// Sets the directory to parse commits from.
#[structopt(long, env, value_name = "PATH")]
pub commit_path: Option<Pattern>,
#[structopt(long, env, value_name = "PATTERN")]
pub commit_path: Option<Vec<Pattern>>,
/// Prepends entries to the given changelog file.
#[structopt(short, long, env, value_name = "PATH")]
pub prepend: Option<PathBuf>,
Expand Down
1 change: 0 additions & 1 deletion git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ pub fn run(mut args: Opt) -> Result<()> {
}
}
let commits = repository.commits(commit_range, args.commit_path)?;

// Update tags.
if let Some(tag) = args.tag {
if let Some(commit_id) = commits.first().map(|c| c.id().to_string()) {
Expand Down

0 comments on commit edb343a

Please sign in to comment.