I have embedded software with the following version-numbering :
<Product Number>.<Major>.<SVN commit number>
The problem is that we swapped from svn to git and we lost the SVN commit number which is "replaced" by SHA.
Thus, we could replace <SVN commit number> by <git commit SHA>. However, we can't do that because we are constrained to 2 bytes for this last versionning-number, and <git commit SHA> is often compressed to 3 bytes.
Is there another way to have a version-numbering taking into account commits?
If you accept the possibility to have an hash composed of just 2 bytes you can use the options --abbrev=<n>
of the git describe
command where n
is the number of bytes you want for your git hash.
In your case it would be:
git describe --always --abbrev=2
Remember that there is the possibility that with just 2 bytes your hash is no more unique, even if it is a remote chance given that it is also related with you version number. The --always
option is needed to show only the hash.