git-cliff icon indicating copy to clipboard operation
git-cliff copied to clipboard

Do not group by tag version

Open stratosgear opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. Sorry, I am not sure if this already doable and I missed it, but what I am interested in is to generate a changelog between two tags. But if the two tags contain other tags in between I do not want to see the inbetween tag versions.

The actual example is that if there are tags like:

v1.0.0. v1.1.0a1, v1.1.0b1, v1.1.0b2, v1.1.0

I might want to have changelogs for releases between v1.0.0 and v1.1.0a1 or v1.1.0a1 and v1.1.0b1 etc, but when I release the final v1.1.0 I want to create another changelog between v1.0.0 and v1.1.0 but without the intermediary tags (there might be a ton of them)

Describe the solution you'd like I guess, a parameter that does not group by tags?

Additional context Here is a dump of what git-cliff currently generates as changelog between two tags:

➜ git cliff v0.40..v0.45
# Changelog
All notable changes to this project will be documented in this file.

## [0.45] - 2021-05-26

### Infra

## [0.44] - 2021-05-24

### Feat

### Fix

## [0.43] - 2021-05-07

### Feat

### Fix

### Infra

## [0.42] - 2021-04-24

### BREAKING

### Feat

### Fix

## [0.41] - 2021-04-14

### BREAKING

<!-- generated by git-cliff -->

stratosgear avatar Sep 07 '21 08:09 stratosgear

Hello!

v1.0.0. v1.1.0a1, v1.1.0b1, v1.1.0b2, v1.1.0

I might want to have changelogs for releases between v1.0.0 and v1.1.0a1 or v1.1.0a1 and v1.1.0b1 etc, but when I release the final v1.1.0 I want to create another changelog between v1.0.0 and v1.1.0 but without the intermediary tags (there might be a ton of them)

🤔 I think I get what you mean. Let's take the following git history in account for example:

* df6aef4 (HEAD -> master, tag: v1.1.0) feat(cache): use cache while fetching pages
* a9d4050 feat(config): support multiple file formats
* 06412ac chore(release): add release script
* e4fd3cf (tag: v1.1.0b2) refactor(parser): expose string functions
* ad27b43 (tag: v1.1.0b1) docs(example)!: add tested usage example
* 9add0d4 (tag: v1.1.0a1) fix(args): rename help argument due to conflict
* a140cef (tag: v1.0.0) feat(parser): add ability to parse arrays
* 81fbc63 docs(project): add README.md
* a78bc36 Initial commit

When we run git-cliff with the default arguments/config, we get:

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

## [1.1.0] - 2021-07-18

### Features

- Support multiple file formats
- Use cache while fetching pages

### Miscellaneous Tasks

- Add release script

## [1.1.0b2] - 2021-07-18

### Refactor

- Expose string functions

## [1.1.0b1] - 2021-07-18

### Documentation

- Add tested usage example

## [1.1.0a1] - 2021-07-18

### Bug Fixes

- Rename help argument due to conflict

## [1.0.0] - 2021-07-18

### Documentation

- Add README.md

### Features

- Add ability to parse arrays

<!-- generated by git-cliff -->

If you want to omit 1.1.0a1, 1.1.0b1 and 1.1.0b2 from the changelog, you can change the value of skip_tags in cliff.toml:

# regex for skipping tags
skip_tags = "v[0-9].[0-9].[0-9][a-zA-Z][0-9]"

example regex: https://regex101.com/r/QGHgC5/1

This results in:

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

## [1.1.0] - 2021-07-18

### Features

- Support multiple file formats
- Use cache while fetching pages

### Miscellaneous Tasks

- Add release script

## [1.0.0] - 2021-07-18

### Documentation

- Add README.md

### Features

- Add ability to parse arrays

<!-- generated by git-cliff -->

Describe the solution you'd like I guess, a parameter that does not group by tags?

As I showed above, this can be solved with skip_tags instead of "not grouping by tags". So you can use n different config files for your use-case. I can also add an argument such as --skip-tags <regex> for convenience. What do you think?

Additional context Here is a dump of what git-cliff currently generates as changelog between two tags:

Does it generate a changelog without any commits like this or is this just an example?

orhun avatar Sep 07 '21 18:09 orhun

Yes, manually I might be able to list all intermediate tags. But what if I want to automate this so it works in a CI environment. Am I do write a script that calculates all the in-between tags?

Wouldn't it be easier to say: you know what? skip all in-between tags! An extra param would do this.

Or even maybe if I could use a wildcard "*" or something for skip_tags so it would ignore all and any tags in between?

So all in all, not really happy/comfortable having to find the in-between tags... :(

stratosgear avatar Sep 07 '21 18:09 stratosgear

Reading a little more careful your previous post:

  1. The result of git cliff v1.0.0..v1.1.0 should not include the commits of v1.0.0 (as your example currently shows), but only all the commits after v1.0.0. Not sure if you typed the example by hand or not.

  2. Regarding the --skip-tags param. If I could put a * (or maybe .* in regex) I guess it would satisfy my needs.

stratosgear avatar Sep 07 '21 18:09 stratosgear

I think I'm seeking the same functionality, only I would describe it more like this: Make git-cliff behave the same as git tag --list <pattern>

For example:

at 17:09:21 ❯ git tag --list
v0.0.1
v0.0.1-compose
v0.0.1-pkg
v0.0.2
v0.0.2-compose
v0.0.2-pkg
v0.0.3
v0.0.3-compose
v0.0.3-pkg
v0.0.4
v0.0.5
v0.1.0
v0.1.1
v0.1.2
v0.1.2-infra
v0.1.3-infra
v0.1.4-infra
v0.1.5-infra
v0.2.0
v0.2.0-app
v0.2.0-jsonnet
v0.2.1-app

Now, let's say I want to just generate a changelog for all commits in the tag v*-infra:

at 21:14:21 ❯ git tag --list 'v*-infra'
v0.1.2-infra
v0.1.3-infra
v0.1.4-infra
v0.1.5-infra

Maybe I want only tags with no suffixes

at 21:22:11 ❯ g tag --list 'v*.[0-9]' 
v0.0.1
v0.0.2
v0.0.3
v0.0.4
v0.0.5
v0.1.0
v0.1.1
v0.1.2
v0.2.0

I think it would be better to use regex vs POSIX RE pattern matching, but I think what I need and what this issue describes are the same issue.

Now the more I've played with this tool, it appears the functionality I seek is provided by using tag_pattern in cliff.toml -- so far so good! Nice!

notjames avatar Aug 29 '23 04:08 notjames

tag_pattern now supports regex (see #318) so you should be able to achieve this.

orhun avatar Dec 30 '23 18:12 orhun