This repository was archived by the owner on Jan 26, 2026. It is now read-only.
fix: the sort order of commits is unstable#210
Open
ikedam wants to merge 1 commit intogit-chglog:masterfrom
Open
fix: the sort order of commits is unstable#210ikedam wants to merge 1 commit intogit-chglog:masterfrom
ikedam wants to merge 1 commit intogit-chglog:masterfrom
Conversation
2 tasks
PSyton
pushed a commit
to PSyton/git-chglog
that referenced
this pull request
Dec 5, 2022
Member
|
@ikedam could you rebase on |
Use `sort.SliceStable` instead of `sort.Slice` to sort commits. Closes git-chglog#209
8ac3388 to
008851b
Compare
Author
|
Rebased. |
Member
|
same here :) checks triggered |
Pull Request Test Coverage Report for Build 3995581080
💛 - Coveralls |
|
Hi :) We got hit by this problem too, is there any chance you can merge this? |
2 tasks
PSyton
pushed a commit
to PSyton/git-chglog
that referenced
this pull request
Sep 17, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
sort.SliceStableinstead ofsort.Sliceto sort commits.Closes #209
What does this do / why do we need it?
This change uses
sort.SliceStableto sort commits: https://pkg.go.dev/sort#SliceStableCurrent implementation uses
sort.Slice, but it's an unstable sort as described in godoc: https://pkg.go.dev/sort#SliceThis results the order of logs indefinite. Especially the order differs when you change
.options.header.patternand the extracted log set changes. I want the order of logs always same. Please refer #209 for an example.How this PR fixes the problem?
sort.SliceStableis a stable sort and the original order is preserved for same priority elements (for example, logs with the same scope). "the original order" is expected to be the commit order.What should your reviewer look out for in this PR?
This change results the log order changed. That means the order of logs in previous releases changes when a developer runs
git-chglogwith this fix for a new release.Please consider whether this is acceptable. If not, I'll introduce a new cli option or configuration option.
(Anyway, the log order can change when the implementation of
sort.Slicein golang is changed...)Check lists
Additional Comments (if any)
There are other lines using
sort.Slice. I believe they don't need to be changed tosort.SliceStableas their sort key is expected to be unique (e.g. Title).Which issue(s) does this PR fix?
fixes #209