diff --git a/.github/fixtures/test-cli-arg-skip-tags/cliff.toml b/.github/fixtures/test-cli-arg-skip-tags/cliff.toml new file mode 100644 index 0000000000..eabd6f85da --- /dev/null +++ b/.github/fixtures/test-cli-arg-skip-tags/cliff.toml @@ -0,0 +1,22 @@ +[changelog] +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits %} + - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" + +[git] +# regex for skipping tags +skip_tags = "" +# regex for ignoring tags +ignore_tags = "" diff --git a/.github/fixtures/test-cli-arg-skip-tags/commit.sh b/.github/fixtures/test-cli-arg-skip-tags/commit.sh new file mode 100755 index 0000000000..4cc91676ac --- /dev/null +++ b/.github/fixtures/test-cli-arg-skip-tags/commit.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add first beta feature" +git tag v1.0.0-beta.1 + +GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add second beta feature" +git tag v1.0.0-beta.2 + +# WARNING: If we won't create this commit, 1.0.0 won't be created! +GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "chore: why do i need a commit here?" +git tag v1.0.0 + +GIT_COMMITTER_DATE="2021-01-23 01:23:49" git commit --allow-empty -m "fix: simple fix" +git tag v1.0.1 diff --git a/.github/fixtures/test-cli-arg-skip-tags/expected.md b/.github/fixtures/test-cli-arg-skip-tags/expected.md new file mode 100644 index 0000000000..359dcdf890 --- /dev/null +++ b/.github/fixtures/test-cli-arg-skip-tags/expected.md @@ -0,0 +1,12 @@ +## [1.0.1] - 2021-01-23 + +### 🐛 Bug Fixes + +- Simple fix + +## [1.0.0] - 2021-01-23 + +### ⚙️ Miscellaneous Tasks + +- Why do i need a commit here? + diff --git a/.github/workflows/test-fixtures.yml b/.github/workflows/test-fixtures.yml index c054eaa5ae..9045f6e58d 100644 --- a/.github/workflows/test-fixtures.yml +++ b/.github/workflows/test-fixtures.yml @@ -100,6 +100,8 @@ jobs: command: --bump --tag=2.1.1 - fixtures-name: test-cli-arg-ignore-tags command: --ignore-tags ".*beta" + - fixtures-name: test-cli-arg-skip-tags + command: --skip-tags ".*beta" - fixtures-name: test-tag-message - fixtures-name: test-bump-unreleased-with-tag-message-arg command: --bump --unreleased --with-tag-message "Some text" diff --git a/git-cliff/src/args.rs b/git-cliff/src/args.rs index 0c2e874246..c972b526d2 100644 --- a/git-cliff/src/args.rs +++ b/git-cliff/src/args.rs @@ -149,6 +149,9 @@ pub struct Opt { num_args = 0..=1, )] pub with_tag_message: Option, + /// Sets the tags to skip in the changelog. + #[arg(long, env = "GIT_CLIFF_SKIP_TAGS", value_name = "PATTERN")] + pub skip_tags: Option, /// Sets the tags to ignore in the changelog. #[arg(long, env = "GIT_CLIFF_IGNORE_TAGS", value_name = "PATTERN")] pub ignore_tags: Option, diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 21abb42b5d..226e734ff1 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -691,6 +691,9 @@ pub fn run_with_changelog_modifier<'a>( .iter_mut() .for_each(|v| v.replace_command = None); } + if args.skip_tags.is_some() { + config.git.skip_tags.clone_from(&args.skip_tags); + } config.git.skip_tags = config.git.skip_tags.filter(|r| !r.as_str().is_empty()); if args.tag_pattern.is_some() { config.git.tag_pattern.clone_from(&args.tag_pattern); diff --git a/website/docs/configuration/git.md b/website/docs/configuration/git.md index a0fd97fb22..bb59051741 100644 --- a/website/docs/configuration/git.md +++ b/website/docs/configuration/git.md @@ -236,6 +236,8 @@ This value can be also overridden with using the `--tag-pattern` argument. A regex for skip processing the matched tags. +This value can be also overridden with using the `--skip-tags` argument. + ### ignore_tags A regex for ignore processing the matched tags. diff --git a/website/docs/usage/args.md b/website/docs/usage/args.md index 52e0d508b3..c1f5be2113 100644 --- a/website/docs/usage/args.md +++ b/website/docs/usage/args.md @@ -39,6 +39,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE] --tag-pattern Sets the regex for matching git tags [env: GIT_CLIFF_TAG_PATTERN=] --with-commit ... Sets custom commit messages to include in the changelog [env: GIT_CLIFF_WITH_COMMIT=] --with-tag-message [] Sets custom message for the latest release [env: GIT_CLIFF_WITH_TAG_MESSAGE=] + --skip-tags Sets the tags to skip in the changelog [env: GIT_CLIFF_SKIP_TAGS=] --ignore-tags Sets the tags to ignore in the changelog [env: GIT_CLIFF_IGNORE_TAGS=] --count-tags Sets the tags to count in the changelog [env: GIT_CLIFF_COUNT_TAGS=] --skip-commit ... Sets commits that will be skipped in the changelog [env: GIT_CLIFF_SKIP_COMMIT=]