On CI server we git clone --depth 1 <repo> and I would like to create a version string for the artifact that is being built. I want my version string to look like this:
0.1.0-15-0bef345-master
Where:
0.1.0is the version obtained from the latest tag, this is easy, usinggit ls-remote.15is the number of commits after the0.1.0tag0bef345is the short hash of the git commitmasteris the branch
Now the question is, how can I get the 15 (amount of commits between a tag and the HEAD).
Normally this is easy git rev-list --count v0.1.0 HEAD, when you have the full history.
How can I do this without having to clone the entire history?