Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(args): add --ignore-tags argument #696

Merged
merged 15 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
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
33 changes: 33 additions & 0 deletions .github/fixtures/test-cli-arg-ignore-tags/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# 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
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing whitespace from the templates
trim = true

[git]
# regex for skipping tags
skip_tags = ""
# regex for ignoring tags
ignore_tags = ""
15 changes: 15 additions & 0 deletions .github/fixtures/test-cli-arg-ignore-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
18 changes: 18 additions & 0 deletions .github/fixtures/test-cli-arg-ignore-tags/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

## [1.0.1] - 2021-01-23

### Fix

- Simple fix

## [1.0.0] - 2021-01-23

### Feat

- Add first beta feature
- Add second beta feature

<!-- generated by git-cliff -->
3 changes: 3 additions & 0 deletions .github/workflows/test-fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
command: --bump
- fixtures-name: test-bump-initial-tag-cli-arg
command: --bump --tag=2.1.1
- fixtures-name: test-cli-arg-ignore-tags
command: --ignore-tags ".*beta"

steps:
- name: Checkout
uses: actions/checkout@v4
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 @@ -142,6 +142,9 @@ pub struct Opt {
num_args(1..)
)]
pub with_commit: Option<Vec<String>>,
/// Sets the tags to ignore in the changelog.
#[arg(long, env = "GIT_CLIFF_IGNORE_TAGS", value_name = "PATTERN")]
pub ignore_tags: Option<Regex>,
/// Sets commits that will be skipped in the changelog.
#[arg(
long,
Expand Down
4 changes: 3 additions & 1 deletion git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ pub fn run(mut args: Opt) -> Result<()> {
if args.tag.is_some() {
config.bump.initial_tag.clone_from(&args.tag);
}

if args.ignore_tags.is_some() {
config.git.ignore_tags.clone_from(&args.ignore_tags);
}
// Process the repositories.
let repositories = args.repository.clone().unwrap_or(vec![env::current_dir()?]);
let mut releases = Vec::<Release>::new();
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 @@ -193,6 +193,8 @@ A regex for skip processing the matched tags.

A regex for ignore processing the matched tags.

This value can be also overridden with using the `--ignore-tags` argument.

While `skip_tags` drop commits from the changelog, `ignore_tags` include ignored commits into the next tag.

### topo_order
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 @@ -35,6 +35,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE]
--exclude-path <PATTERN>... Sets the path to exclude related commits [env: GIT_CLIFF_EXCLUDE_PATH=]
--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=]
--ignore-tags <PATTERN> Sets the tags to ignore in the changelog [env: GIT_CLIFF_IGNORE_TAGS=]
--skip-commit <SHA1>... Sets commits that will be skipped in the changelog [env: GIT_CLIFF_SKIP_COMMIT=]
-p, --prepend <PATH> Prepends entries to the given changelog file [env: GIT_CLIFF_PREPEND=]
-o, --output [<PATH>] Writes output to the given file [env: GIT_CLIFF_OUTPUT=]
Expand Down
Loading