Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/fixtures/test-cli-arg-skip-tags/cliff.toml
Original file line number Diff line number Diff line change
@@ -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 = ""
15 changes: 15 additions & 0 deletions .github/fixtures/test-cli-arg-skip-tags/commit.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .github/fixtures/test-cli-arg-skip-tags/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## [1.0.1] - 2021-01-22

### <!-- 1 -->🐛 Bug Fixes

- Simple fix

## [1.0.0] - 2021-01-22

### <!-- 7 -->⚙️ Miscellaneous Tasks

- Why do i need a commit here?

2 changes: 2 additions & 0 deletions .github/workflows/test-fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ pub struct Opt {
num_args = 0..=1,
)]
pub with_tag_message: Option<String>,
/// Sets the tags to skip in the changelog.
#[arg(long, env = "GIT_CLIFF_SKIP_TAGS", value_name = "PATTERN")]
pub skip_tags: Option<Regex>,
/// Sets the tags to ignore in the changelog.
#[arg(long, env = "GIT_CLIFF_IGNORE_TAGS", value_name = "PATTERN")]
pub ignore_tags: Option<Regex>,
Expand Down
3 changes: 3 additions & 0 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions website/docs/configuration/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/usage/args.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE]
--tag-pattern <PATTERN> Sets the regex for matching git tags [env: GIT_CLIFF_TAG_PATTERN=]
--with-commit <MSG>... Sets custom commit messages to include in the changelog [env: GIT_CLIFF_WITH_COMMIT=]
--with-tag-message [<MSG>] Sets custom message for the latest release [env: GIT_CLIFF_WITH_TAG_MESSAGE=]
--skip_tags <PATTERN> Sets the tags to skip in the changelog [env: GIT_CLIFF_SKIP_TAGS=]
--ignore-tags <PATTERN> Sets the tags to ignore in the changelog [env: GIT_CLIFF_IGNORE_TAGS=]
--count-tags <PATTERN> Sets the tags to count in the changelog [env: GIT_CLIFF_COUNT_TAGS=]
--skip-commit <SHA1>... Sets commits that will be skipped in the changelog [env: GIT_CLIFF_SKIP_COMMIT=]
Expand Down
Loading