Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit sotring is unstable #209

Open
ikedam opened this issue Sep 17, 2022 · 0 comments · May be fixed by #210
Open

Commit sotring is unstable #209

ikedam opened this issue Sep 17, 2022 · 0 comments · May be fixed by #210
Milestone

Comments

@ikedam
Copy link

ikedam commented Sep 17, 2022

Expected Behavior

The order of log entries are always same for any configurations if options.commits.sort_by is not changed.

Actual Behavior

The order of log entries differs for different configurations, even if options.commits.sort_by is not changed.
This means the sorting for commit is performed with an unstable sort algorithm.

Steps to Reproduce (including precondition)

  1. Create a changelog for git-chglog@v0.11.0:

    $ ./git-chglog v0.11.0 >changelog1.md 
    
  2. Change the configuration:

    diff --git a/.chglog/config.yml b/.chglog/config.yml
    index 074a182..5473a51 100755
    --- a/.chglog/config.yml
    +++ b/.chglog/config.yml
    @@ -20,7 +20,7 @@ options:
           refactor: Code Refactoring
           chore: Chores
       header:
    -    pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
    +    pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(update module .*)$"
         pattern_maps:
           - Type
           - Scope
    
    • This means to generate a changelog only with logs started with "update module ...".
  3. Create a changelog for git-chglog@v0.11.0 with the new configuration:

    $ ./git-chglog v0.11.0 >changelog2.md 
    
  4. Compare them:

    $ diff -u changelog1.md changelog2.md
    
    • Attached this output: diff_of_changelogs.txt
    • There are differences not only for removed lines but also for added lines. This is caused for the order of logs changed.

I found this behavior when I updated the git-chglog configuration for my repository to pick new commits. I expected new logs, but didn't expected changing the order of logs.

Screenshot on This Problem (if possible)

N/A

Your Environment

  • OS: golang:1.19.1-bullseye (Tested with docker)
  • git-chglog version: v0.15.1 (Built in golang:1.19.1-bullseye)
ikedam added a commit to ikedam/git-chglog that referenced this issue Sep 17, 2022
Use `sort.SliceStable` instead of `sort.Slice` to sort commits.

Closes git-chglog#209
@ikedam ikedam linked a pull request Sep 17, 2022 that will close this issue
2 tasks
ikedam added a commit to ikedam/git-chglog that referenced this issue Jan 24, 2023
Use `sort.SliceStable` instead of `sort.Slice` to sort commits.

Closes git-chglog#209
@mavogel mavogel added this to the v0.16.0 milestone Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants