mirror of
https://github.com/orhun/git-cliff.git
synced 2024-08-16 18:30:30 +03:00
Merge cc2b748060
into 4a3edcaf5d
This commit is contained in:
commit
639d61a78e
34
.github/fixtures/test-invert-ignore-tags/cliff.toml
vendored
Normal file
34
.github/fixtures/test-invert-ignore-tags/cliff.toml
vendored
Normal 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"
|
15
.github/fixtures/test-invert-ignore-tags/commit.sh
vendored
Executable file
15
.github/fixtures/test-invert-ignore-tags/commit.sh
vendored
Executable 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
|
14
.github/fixtures/test-invert-ignore-tags/expected.md
vendored
Normal file
14
.github/fixtures/test-invert-ignore-tags/expected.md
vendored
Normal 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 -->
|
1
.github/workflows/test-fixtures.yml
vendored
1
.github/workflows/test-fixtures.yml
vendored
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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![
|
||||
|
@ -88,12 +88,23 @@ 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 = tags
|
||||
.into_iter()
|
||||
.filter(|(_, name)| {
|
||||
// Keep skip tags to drop commits in the later stage.
|
||||
let skip = skip_regex.map(|r| r.is_match(name)).unwrap_or_default();
|
||||
|
||||
let count = count_tags
|
||||
.map(|r| {
|
||||
let count_tag = r.is_match(name);
|
||||
if count_tag {
|
||||
trace!("Counting release: {}", name)
|
||||
}
|
||||
count_tag
|
||||
})
|
||||
.unwrap_or(true);
|
||||
|
||||
let ignore = ignore_regex
|
||||
.map(|r| {
|
||||
if r.as_str().trim().is_empty() {
|
||||
@ -108,7 +119,7 @@ fn process_repository<'a>(
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
skip || !ignore
|
||||
skip || (count && !ignore)
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user