SyneRBI / SyneRBI_VM

Virtual Machine with pre-installed SyneRBI software
http://www.ccpsynerbi.ac.uk
Apache License 2.0
3 stars 7 forks source link

Wrong order of git tags #135

Closed paskino closed 5 years ago

paskino commented 5 years ago

Evgueni just discovered a bug in how the VM gets the most recent tag. The command that we issue is git fetch; git for-each-ref refs/tags/v* --sort=-taggerdate --format='%(refname:short)' --count=1

and the result is v2.0.0-rc.4

git tag returns

v0.9.0
v0.9.0-rc1
v0.9.0-rc2
v0.9.0-rc3
v0.9.1
v0.9.1-rc1
v0.9.2
v1.0.0
v1.0.0-rc.1
v1.0.0-rc.2
v1.0.0-rc.3
v1.1.0
v1.1.0-rc.1
v1.1.1
v2.0.0
v2.0.0-rc.1
v2.0.0-rc.2
v2.0.0-rc.3
v2.0.0-rc.4

Therefore the 2.0.0 tag is there, just not picked. BTW on github the order of the tags is correct https://github.com/CCPPETMR/SIRF-SuperBuild/releases

How do we get the tags in the proper order?

KrisThielemans commented 5 years ago

The for “git for-each-ref” stuff is likely from pre-git 2.0 days, see e.g. https://stackoverflow.com/questions/14273531/how-to-sort-git-tags-by-version-string-order-of-form-rc-x-y-z-w

but should be equivalent to using git tag --sort=taggerdate Here's what I get with updated get

 git tag --sort=taggerdate
v0.9.1
v0.9.1-rc1
v2.0.0
v2.0.0-rc.1
v0.9.0-rc1
v0.9.0-rc2
v0.9.0-rc3
v0.9.0
v0.9.2
v1.0.0-rc.1
v1.0.0-rc.2
v1.0.0-rc.3
v1.0.0
v1.1.0-rc.1
v1.1.0
v1.1.1
v2.0.0-rc.2
v2.0.0-rc.3
v2.0.0-rc.4

while

 git tag --sort=committerdate
v0.9.0
v0.9.0-rc1
v0.9.0-rc2
v0.9.0-rc3
v0.9.2
v1.0.0
v1.0.0-rc.1
v1.0.0-rc.2
v1.0.0-rc.3
v1.1.0
v1.1.0-rc.1
v1.1.1
v2.0.0-rc.2
v2.0.0-rc.3
v2.0.0-rc.4
v0.9.1-rc1
v0.9.1
v2.0.0-rc.1
v2.0.0

and

git tag --sort=version:refname
v0.9.0
v0.9.0-rc1
v0.9.0-rc2
v0.9.0-rc3
v0.9.1
v0.9.1-rc1
v0.9.2
v1.0.0
v1.0.0-rc.1
v1.0.0-rc.2
v1.0.0-rc.3
v1.1.0
v1.1.0-rc.1
v1.1.1
v2.0.0
v2.0.0-rc.1
v2.0.0-rc.2
v2.0.0-rc.3
v2.0.0-rc.4

The taggerdate is different from yours...

KrisThielemans commented 5 years ago

It turns out that v2.0.0 is not an annotated tag.

 git for-each-ref refs/tags
1a32e06d82689dcf8d00e1e9c6e2b121f44952d0 tag    refs/tags/v0.9.0
b4679ac5b453ac584c5bc26d272e5f41f2e42b06 tag    refs/tags/v0.9.0-rc1
2b161cc5ca50632b979bdec7e2d25e7a5b6b9c67 tag    refs/tags/v0.9.0-rc2
ad54cbbbd597ad5bb8095f8e4b18b278fdb302d8 tag    refs/tags/v0.9.0-rc3
f71cb156cebed24b71ce58a9c3b970d79650efd9 commit refs/tags/v0.9.1
e19a27e5b9e3277b677a71861d9490b86b8958d5 commit refs/tags/v0.9.1-rc1
a3520241cb9691ce3def08502c12bd51f032367d tag    refs/tags/v0.9.2
a46df479eb9b24b098c0c998f2967428212b5adc tag    refs/tags/v1.0.0
eda66b342f652dfa7dd9b76a95a2d9e139ee6aec tag    refs/tags/v1.0.0-rc.1
4529f904e067ef54072760c9d5b15e08fc633bdf tag    refs/tags/v1.0.0-rc.2
564f120ab3e8cd4bc2cbbf7419e788a13983f390 tag    refs/tags/v1.0.0-rc.3
22f714d1b698ce7f1190c8759664cbfbd3953ff3 tag    refs/tags/v1.1.0
46d8e2ae2bca0a335f56d28b7a94ae2e29df21ef tag    refs/tags/v1.1.0-rc.1
e7696ffd0481ecdb7c5884560a12774c4955e6b3 tag    refs/tags/v1.1.1
bf08453e90466e760e14b97bd231cc89e1be573a commit refs/tags/v2.0.0
76c6c6fc5cb6e5c14b0fcf74d01f9efbb9e4e738 commit refs/tags/v2.0.0-rc.1
05b6584d050b015dba1808ff99a2c4ab4f0cfc1f tag    refs/tags/v2.0.0-rc.2
61b1f89c75cc1421a94e81bb155e4d1d49f7759b tag    refs/tags/v2.0.0-rc.3
895e4f926cccd4e3a1f31332cdb318929c6d03cf tag    refs/tags/v2.0.0-rc.4

We have had this before.

paskino commented 5 years ago

That's nice! :( I created the tag on the web interface and didn't click on "this is a pre release" which I thought would create a not annotated tag.

Anyway, I asked my local git guru and the suggestion was to sort the tags by ourselves and not rely on git.

I believe that this command does the job

git tag | xargs -I@ git log --format=format:"%at @%n" -1 @ | sort | awk '{print $2}' | tail -1

It takes the tags and passes them as argument to git log. Then we format the output of git log to contain the unix timestamp and the tag. then sort it by the timestamp and print only the tag and get the last line.

@KrisThielemans has a point saying,

The question here is obviously what timestamp to use (author, commit, tagger). At first sight, you’d think they are all the same, but they are not when merging (and definitely not when rebasing).

KrisThielemans commented 5 years ago

The annotated tag thing happened before. We have the checklist to avoid repeating mistakes :-; Please don't try to use shortcuts I guess.

The above line seems to work fine, but can't say it's simple. Further discussion on how to get sorting and dates at #136

KrisThielemans commented 5 years ago

Closed with #136