1
1
mirror of https://github.com/orhun/git-cliff.git synced 2024-09-11 15:05:30 +03:00

Compare commits

...

3 Commits

Author SHA1 Message Date
dependabot[bot]
37a554d0a9
Merge fa8e2b7db1 into b8045e97ed 2024-08-15 14:53:02 -07:00
tison
b8045e97ed
feat(changelog): support count_tags option (#599)
* feat: support count_tags option

Signed-off-by: tison <wander4096@gmail.com>

* add fixures tags

Signed-off-by: tison <wander4096@gmail.com>

* fixup

Signed-off-by: tison <wander4096@gmail.com>

* add count_tags to args

Signed-off-by: tison <wander4096@gmail.com>

* add docs

Signed-off-by: tison <wander4096@gmail.com>

* run cargo fmt

Signed-off-by: tison <wander4096@gmail.com>

* fixup default to true

Signed-off-by: tison <wander4096@gmail.com>

* docs(website): update documentation about count_tags

---------

Signed-off-by: tison <wander4096@gmail.com>
Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2024-08-13 12:22:54 +03:00
dependabot[bot]
fa8e2b7db1
chore(deps): bump rust-embed from 8.4.0 to 8.5.0
Bumps [rust-embed](https://github.com/pyros2097/rust-embed) from 8.4.0 to 8.5.0.
- [Changelog](https://github.com/pyrossh/rust-embed/blob/master/changelog.md)
- [Commits](https://github.com/pyros2097/rust-embed/commits)

---
updated-dependencies:
- dependency-name: rust-embed
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-29 08:29:38 +00:00
13 changed files with 166 additions and 63 deletions

View File

@ -0,0 +1,34 @@
[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 = "v0.1.0-beta.1"
# regex for ignoring tags
ignore_tags = "v.*-beta.*"
count_tags = "v0.2.0"

View File

@ -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 skip feature"
git tag v0.1.0-beta.1
GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 1"
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.0
GIT_COMMITTER_DATE="2021-01-23 01:23:48" git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0-beta.1
GIT_COMMITTER_DATE="2021-01-23 01:23:49" git commit --allow-empty -m "feat: add feature 3"
git tag v0.2.0

View File

@ -0,0 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.
## [0.2.0] - 2021-01-23
### Feat
- Add feature 1
- Fix feature 1
- Add feature 2
- Add feature 3
<!-- generated by git-cliff -->

View File

@ -22,6 +22,7 @@ jobs:
- fixtures-name: test-gitea-integration
- fixtures-name: test-bitbucket-integration
- fixtures-name: test-ignore-tags
- fixtures-name: test-invert-ignore-tags
- fixtures-name: test-topo-order
command: --latest
- fixtures-name: test-date-order

115
Cargo.lock generated
View File

@ -45,6 +45,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "allocator-api2"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "android-tzdata"
version = "0.1.1"
@ -143,7 +149,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -375,7 +381,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -453,6 +459,15 @@ version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]]
name = "core2"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505"
dependencies = [
"memchr",
]
[[package]]
name = "cpp_demangle"
version = "0.4.3"
@ -515,6 +530,12 @@ dependencies = [
"typenum",
]
[[package]]
name = "dary_heap"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca"
[[package]]
name = "debugid"
version = "0.8.0"
@ -771,7 +792,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -973,6 +994,10 @@ name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]]
name = "heck"
@ -1276,36 +1301,25 @@ dependencies = [
[[package]]
name = "include-flate"
version = "0.2.0"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e11569346406931d20276cc460215ee2826e7cad43aa986999cb244dd7adb0"
checksum = "df49c16750695486c1f34de05da5b7438096156466e7f76c38fcdf285cf0113e"
dependencies = [
"include-flate-codegen-exports",
"include-flate-codegen",
"lazy_static",
"libflate",
]
[[package]]
name = "include-flate-codegen"
version = "0.1.4"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a7d6e1419fa3129eb0802b4c99603c0d425c79fb5d76191d5a20d0ab0d664e8"
checksum = "8c5b246c6261be723b85c61ecf87804e8ea4a35cb68be0ff282ed84b95ffe7d7"
dependencies = [
"libflate",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "include-flate-codegen-exports"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75657043ffe3d8280f1cb8aef0f505532b392ed7758e0baeac22edadcee31a03"
dependencies = [
"include-flate-codegen",
"proc-macro-hack",
"syn",
]
[[package]]
@ -1425,7 +1439,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex",
"syn 2.0.63",
"syn",
]
[[package]]
@ -1442,21 +1456,25 @@ checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "libflate"
version = "1.4.0"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18"
checksum = "45d9dfdc14ea4ef0900c1cddbc8dcd553fbaacd8a4a282cf4018ae9dd04fb21e"
dependencies = [
"adler32",
"core2",
"crc32fast",
"dary_heap",
"libflate_lz77",
]
[[package]]
name = "libflate_lz77"
version = "1.2.0"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf"
checksum = "e6e0d73b369f386f1c44abd9c570d5318f55ccde816ff4b562fa452e5182863d"
dependencies = [
"core2",
"hashbrown",
"rle-decode-fast",
]
@ -1578,7 +1596,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -1782,7 +1800,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -1851,7 +1869,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -1921,12 +1939,6 @@ dependencies = [
"yansi",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
version = "1.0.82"
@ -2229,9 +2241,9 @@ checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
[[package]]
name = "rust-embed"
version = "8.4.0"
version = "8.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19549741604902eb99a7ed0ee177a0663ee1eda51a29f71401f166e47e77806a"
checksum = "fa66af4a4fdd5e7ebc276f115e895611a34739a9c1c01028383d612d550953c0"
dependencies = [
"include-flate",
"rust-embed-impl",
@ -2248,7 +2260,7 @@ dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn 2.0.63",
"syn",
"walkdir",
]
@ -2437,7 +2449,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -2635,17 +2647,6 @@ dependencies = [
"symbolic-common",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.63"
@ -2766,7 +2767,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -2840,7 +2841,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -2970,7 +2971,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -3219,7 +3220,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
"wasm-bindgen-shared",
]
@ -3253,7 +3254,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -3359,7 +3360,7 @@ checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -3370,7 +3371,7 @@ checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]
@ -3588,7 +3589,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
"syn",
]
[[package]]

View File

@ -93,7 +93,7 @@ version = "0.12.6"
features = ["serde"]
[dependencies.rust-embed]
version = "8.4.0"
version = "8.5.0"
features = ["debug-embed", "compression"]
[dev-dependencies]

View File

@ -784,6 +784,7 @@ mod test {
tag_pattern: None,
skip_tags: Regex::new("v3.*").ok(),
ignore_tags: None,
count_tags: None,
topo_order: Some(false),
sort_commits: Some(String::from("oldest")),
link_parsers: None,

View File

@ -109,6 +109,9 @@ pub struct GitConfig {
/// Regex to ignore matched tags.
#[serde(with = "serde_regex", default)]
pub ignore_tags: Option<Regex>,
/// Regex to count matched tags.
#[serde(with = "serde_regex", default)]
pub count_tags: Option<Regex>,
/// Whether to sort tags topologically.
pub topo_order: Option<bool>,
/// Sorting of the commits inside sections.

View File

@ -118,6 +118,7 @@ fn generate_changelog() -> Result<()> {
tag_pattern: None,
skip_tags: None,
ignore_tags: None,
count_tags: None,
topo_order: None,
sort_commits: None,
link_parsers: Some(vec![

View File

@ -154,6 +154,9 @@ pub struct Opt {
/// Sets the tags to ignore in the changelog.
#[arg(long, env = "GIT_CLIFF_IGNORE_TAGS", value_name = "PATTERN")]
pub ignore_tags: Option<Regex>,
/// Sets the tags to count in the changelog.
#[arg(long, env = "GIT_CLIFF_COUNT_TAGS", value_name = "PATTERN")]
pub count_tags: Option<Regex>,
/// Sets commits that will be skipped in the changelog.
#[arg(
long,

View File

@ -86,6 +86,7 @@ fn process_repository<'a>(
let mut tags = repository.tags(&config.git.tag_pattern, args.topo_order)?;
let skip_regex = config.git.skip_tags.as_ref();
let ignore_regex = config.git.ignore_tags.as_ref();
let count_tags = config.git.count_tags.as_ref();
tags.retain(|_, tag| {
let name = &tag.name;
@ -95,6 +96,14 @@ fn process_repository<'a>(
return true;
}
let count = count_tags.map_or(true, |r| {
let count_tag = r.is_match(name);
if count_tag {
trace!("Counting release: {}", name)
}
count_tag
});
let ignore = ignore_regex.is_some_and(|r| {
if r.as_str().trim().is_empty() {
return false;
@ -106,7 +115,8 @@ fn process_repository<'a>(
}
ignore_tag
});
!ignore
count && !ignore
});
if !config.remote.github.is_set() {
@ -508,6 +518,9 @@ pub fn run(mut args: Opt) -> Result<()> {
if args.ignore_tags.is_some() {
config.git.ignore_tags.clone_from(&args.ignore_tags);
}
if args.count_tags.is_some() {
config.git.count_tags.clone_from(&args.count_tags);
}
// Process the repositories.
let repositories = args.repository.clone().unwrap_or(vec![env::current_dir()?]);
let mut releases = Vec::<Release>::new();

View File

@ -200,12 +200,28 @@ 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.
* Note that if a commit has multiple tags, any matched tag will result in all associated tags being ignored, including those not explicitly matched by the regex. This is because git-cliff processes tags at the commit level rather than individually.
For more details, you can view the discussion [here](https://github.com/orhun/git-cliff/discussions/707)
:::note
Note that if a commit has multiple tags, any matched tag will result in all associated tags being ignored, including those not explicitly matched by the regex. This is because git-cliff processes tags at the commit level rather than individually.
For more details, you can view the discussion [here](https://github.com/orhun/git-cliff/discussions/707).
:::
This value can be also overridden with using the `--ignore-tags` argument.
### count_tags
A regex for _counting in_ the matched tags in the final result.
:::info
`count_tags` work like an inverted version of `ignore_tags`, that include all the commits but only count the specific tags.
:::
This value can be also overridden with using the `--count-tags` argument.
### topo_order

View File

@ -37,6 +37,7 @@ git-cliff [FLAGS] [OPTIONS] [--] [RANGE]
--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=]
--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=]
-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=]