Git Snapshot Versioning?

With our SVN repository, we version SVN snapshots using the SVN revision number — we tack “svn-r$REVISION” on the end of the normal version number. This works well, and it’s easy to tell if a given snapshot is newer or older than another one.

Git doesn’t have revision numbers. Commits are identified by SHA1 checksums. Since these are “random,” there’s no way to tell chronological order. How are other people doing git snapshot versioning? The best I’ve come up with is to parse git-log output to get the date and time of the last commit, and then do something like X.Y.Zgit-YYYYMMDD.HHMMSS… which is rather long and ugly. I guess it would be ok to use a 2-digit year here, though. And maybe drop the seconds bit, but I think it’s decently possible to have more than one commit in the same minute. But still… long and ugly.

Any other ideas? My requirements are simple: easy to tell based on just the version string if a snapshot is older or newer than another, must be able to automatically generate this tag, and must be able to identify the exact HEAD that the snapshot was made from.

2 Comments

Filed under everything, software

2 Responses to Git Snapshot Versioning?

  1. I don’t know how to handle that case, but here is my thought: IMHO you need the checksum in all cases, this way you can refer to it in the log. AFAIR the first 6 or 9 numbers are enough to identify the commit. So perhaps something like YYYYMMDD-CCCCCC where C is the checksum. Also the snapshots are daily, so the HH part can be dropped.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>