orhun / git-cliff

A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️
https://git-cliff.org
Apache License 2.0
9.05k stars 189 forks source link

Support limiting the number of tags to process #844

Open dbwodlf3 opened 3 weeks ago

dbwodlf3 commented 3 weeks ago

Is there an existing issue or pull request for this?

Feature description

git-cliff --tag-pattern (?i)prod-.* --tag-n 3

Desired solution

If there are tags like prod-240601, prod-240701, prod-240801, prod-240901, and the latest tag prod-241001, only prod-241001, prod-240901 and prod-240801 should be selected.

Alternatives considered

already there are tag pattern options, it is very easy to add this option.

Additional context

Example shell script
#!/bin/bash

tags=$(git tag -i --sort=taggerdate -l "prod-*" | tail -n 3)
first=$(echo "$tags" | head -n 1)
last=$(echo "$tags" | tail -n 1)
range=$(echo "$first..$last")

git-cliff --tag-pattern "(?i)prod-*" $range -o changelog.md
welcome[bot] commented 3 weeks ago

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

orhun commented 3 weeks ago

Hello, thanks for the issue 👋🏼

Can you give more details about your use case? I'm curious if 3 is just an arbitrary number of if you have a semver-related use case of some sort.

Also, is the example shell script you attached working fine as a workaround?

already there are tag pattern options, it is very easy to add this option.

We already have limit_commits option, I think we can also add limit_tags. Would you be interested in contributing? 🐻

dbwodlf3 commented 3 weeks ago

the 3 is just arbitrary number to test.

The example shell script works well in my pipeline. (Actually, I had to do a few things, but after a few days, git-cliff supported my wrapper code with more features, like JSON export. 😭)

We generate the git-cliff JSON, convert it to ADF (Atlassian Document Format), and post it on Confluence as part of the monthly scheduled release.

okay i will do it. If you don't mind reviewing my code

orhun commented 2 weeks ago

okay i will do it. If you don't mind reviewing my code

Yup, please go ahead!

We generate the git-cliff JSON, convert it to ADF (Atlassian Document Format), and post it on Confluence as part of the monthly scheduled release.

Have you seen the new --from-context option, it sounds like it might also come in handy for your use case :)