For Hypothes.is, I've been using git describe
s --always
option for generating version numbers. However, Chrome apps can only have digits (and '.') in their version identifiers. For that reason, instead of ending up with 0.0.6-1371-g93b5d9d
(which is what versioneer generates for me), I've been publishing extensions that strip off the git hash.
When something goes wrong in production, the clear question is "what git hash was this extension built from?"
Here's my bash script to recover a git hash from a version like "0.0.6-1371" (in our case this means 1371 commits since v0.0.6).
It's easy: use git rev-list
to count the commits since the tag. Then, subtract from that the trailing count in our version number to get the difference. Finally, skip back that amount from HEAD (important: in topological order).