git-chglog / git-chglog

CHANGELOG generator implemented in Go (Golang).
https://godoc.org/github.com/git-chglog/git-chglog
MIT License
2.69k stars 235 forks source link

Issue with semver sort and --next-tag flag #145

Open ldelossa opened 3 years ago

ldelossa commented 3 years ago

I believe the semver ordering does not work correctly when "--next-release" is used.

I can confirm that when I use semver sorting and a backport is the target of the "--next-tag" tag, the generated change log places this backport semver number on the top, which is incorrect.

Once the tag is actually pushed to the repository and git-chglog sees the real one, the order is fixed on the next changelog generation.

Expected Behavior

using "--next-tag" creates a synthetic tag, real enough to cause the appropriate sorting of changelog lines of the fictitious tag. release

Actual Behavior

If the "--next-tag" field is a backport, lower then the current head tag, it will be placed on top.

Steps to Reproduce (including precondition)

Use semver sorting.

Create a tag of v0.1.0, v0.2.0 and ensure they order correctly.

Create a change log with "--next-tag" v0.1.5. It will appear at the top of the list, not in semver ordered.

Your Environment

clok commented 3 years ago

Thanks for the write up. This feels like it's in the same code that I am looking at to enable running the tool with no tags and no next-tag provided.

I think this has to do with how the tool currently simulates a git-tag in a slice to create the next tag.

Just off the top of my head, I feel like we could perform a sorted search and inset on the git-tag slice instead of putting it at the head of the slice (which results in the mocked tag for next-tag being at the top of the changelog)