mirror of
https://github.com/orhun/git-cliff.git
synced 2025-01-05 22:54:48 +03:00
feat(args): support multiple values for --commit-path
argument
This commit is contained in:
parent
ad11cbf6c5
commit
edb343a10e
22
README.md
22
README.md
@ -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:**
|
||||
@ -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:
|
||||
|
@ -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)?;
|
||||
@ -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))
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -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>,
|
||||
|
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user