git-changelog-lib
git-changelog-lib copied to clipboard
Ignore reverted commits when generating changelogs
In case when there is commit + revert commit (with ref to the original commit) within a single version/tag, it would make sense to exclude both of them from commits passed for changelog rendering as they should basically cancel each other anyway. It would be nice to have it at least as an optional feature that can be enabled using configuration.
GitLab's changelog generator seems to have similar feature already, see:
- https://gitlab.com/gitlab-com/gl-infra/delivery/-/issues/1583
- https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55537
See this test case: https://github.com/tomasbjerre/git-changelog-lib/blob/d42e8fa63405b1d152e47d39dd48643bde82b1f8/src/test/java/se/bjurr/gitchangelog/api/GitChangelogApiTest.java#L310
Where git history is:
* 4c6e078 - doing change 2
* 05866f7 - Revert "doing change 1"
* 114a917 - doing change 1
* 5973dd5 - Updating changelog with 1.147.2 [GRADLE SCRIPT]
* aa1fd33 - (tag: 1.147.2) New version: 1.147.2 [GRADLE SCRIPT]
This template: https://github.com/tomasbjerre/git-changelog-lib/blob/d42e8fa63405b1d152e47d39dd48643bde82b1f8/src/test/resources/templatetest/testThatRevertedCommitsAreRemoved.mustache
Gives this result: https://github.com/tomasbjerre/git-changelog-lib/blob/d42e8fa63405b1d152e47d39dd48643bde82b1f8/src/test/java/se/bjurr/gitchangelog/api/GitChangelogApiTest.testThatRevertedCommitsAreRemoved.approved.txt#L38
Is this what you want?
Yes, that is what I meant. I'd just note following:
- It should also work for case when multiple commits are reverted using single revert commit.
- What happens when there is revert commit of other revert commit(s) is something to consider too.