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

fix: sort tags by commit order #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

evanchaoli
Copy link
Contributor

What does this do / why do we need it?

Currently git-chglog tool sorts tags by taggerdate or authordate, which may is not reliable.

For example, in our workflow, we may do the following:

Say, at day 1, our repo has the following commits:

commit-1
commit-2
commit-3

we tested commit-3, and tag it as stg-1. And commits keep growing:

commit-1
commit-2
commit-3 (stg-1)
commit-4
commit-5

At day 2, we tested commit-5, and we tag commit-5 as stg-2:

commit-1
commit-2
commit-3 (stg-1)
commit-4
commit-5 (stg-2)

At day 3, we release commit-3, so we tag commit-3 as prd-3:

commit-1
commit-2
commit-3 (stg-1, prd-1)
commit-4
commit-5 (stg-2)

At day 4, we want to see changes between last prod release (prd-1) and last stage release (stg-2), the expected result should be commit-4 and comit-5.

But current git-chglog cannot generate the correct change logs, because prd-1 is created later than stg-2.

How this PR fixes the problem?

This PR changes the way of tag sorting by date.

git log --oneline --decorate=short can generate commit history with tags on each commit, like:

f1bb0d1 (tag: stg-0.1.0-20210702-34-f1bb0d1, tag: dev-0.1.0-20210702-34-f1bb0d1) xxxx
312f701 xxxxxxx
4eb6495 (tag: stg-0.1.0-20210629-33-4eb6495, tag: dev-0.1.0-20210629-33-4eb6495) xxxx
f3c1554 xxxx
6f3a743 (tag: stg-0.1.0-20210624-32-6f3a743, tag: dev-0.1.0-20210624-32-6f3a743) xxxx
7ebc95f xxxx

We can sort tags with this order.

What should your reviewer look out for in this PR?

  • Do we still need to keep Date field in Tag and RelateTag? I don't know if change log may refer to tag's date. If yes, we should keep it; otherwise tag date is useless then.

Check lists

  • Test passed
  • Coding style (indentation, etc)

Additional Comments (if any)

{Please write here}

Which issue(s) does this PR fix?

@coveralls
Copy link

coveralls commented Aug 12, 2021

Pull Request Test Coverage Report for Build 1123216732

  • 30 of 37 (81.08%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 76.819%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tag_reader.go 30 37 81.08%
Files with Coverage Reduction New Missed Lines %
tag_reader.go 1 92.81%
Totals Coverage Status
Change from base Build 1097947313: 0.01%
Covered Lines: 1869
Relevant Lines: 2433

💛 - Coveralls

Signed-off-by: Evan <chaol@vmware.com>
@evanchaoli evanchaoli force-pushed the fix-sort-by-date branch 3 times, most recently from c1ef66b to 2d760a3 Compare August 12, 2021 08:32
Signed-off-by: Evan <chaol@vmware.com>
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 this pull request may close these issues.

3 participants