0

I am working on git following gitflow (with feature branches and hotfix). Each commit is as follows " [ticket ID]: message "

With jenkins I would like to generate a changelog between 2 tags, but I don't know how to do this correctly.

If I do a git log TagFrom...TagTo it seems to order the commits by creation date this causes problems. The list of commits does not match how the changes have been released. However, the bitbucket website does show them in the correct order.

I have also tried git-changelog-command-line plugins but it seems to have the same issue.

What would be the correct way to get the changes between two tags working with this branch model.

The git log --oneline command seems to order them correctly.

user60108
  • 3,270
  • 2
  • 27
  • 43

1 Answers1

1

I would like to generate a changelog between 2 tags

You have two problems here:

  1. The notion of "between" often doesn't make sense in a Git commit graph.
  2. git log has to sort commits, and you wish to control the sort order.

Problem #2 might be solved for you by using --topo-order or other git log options. But this is not clear to me, because you say:

The git log --oneline command seems to order them correctly

and yet --oneline merely means --pretty=oneline --abbrev-commit; it does not imply --topo-order. I suspect you may be combining it with --graph and --graph does imply --topo-order.

You may find that --ancestry-path helps with your notion of "between" for the tags. You probably do not want the three-dot syntax TagFrom...TagTo, which means commits reachable from either tag but not from both tags. You may want TagOld..TagNew and you may want to add --ancestry-path. See also List commits between 2 commit hashes in git.

torek
  • 448,244
  • 59
  • 642
  • 775
  • Excuse my ignorance, I couldn't understand if the `--ancestry-path` option solves problem 1. So the command to use to get the new commits between two versions would be `git log --topo-order --ancestry-path tagOld..tagNew`? – user60108 May 25 '22 at 14:09
  • I did not say that it would solve it, I said that it *might* **help** with it. See the linked question and its accepted answer for details. – torek May 26 '22 at 00:27