suggestion: automatic version string from GIT repository

169 views
Skip to first unread message

Assaf Gordon

unread,
Feb 16, 2012, 5:39:18 PM2/16/12
to bedtools...@googlegroups.com
Hi Aaron,

May I ask for a small maintenance feature?
I would like to have the reported version (in ./src/utils/version/version.h) to be automatically generated from the Git repository (either by tag or by changeset hash).

This would help when working with different development version (for example, with the "-woa" bug that you've fixed, but the reported version is still 2.15.0 - there's no easy way to know if a user is using the fixed version or not).

The Makefile additions to regenerate "version.h" are here:
https://github.com/agordon/bedtools/tree/feature/auto_git_version

The changes are relatively small:
https://github.com/agordon/bedtools/commit/d0f146c8a1bfe3bbff39f68638e21618bbde2d80


Technically, it works like this:
every time you run "make", the string from "version.h" is compared with the version reported by "git".
if they differ, "version.h" is re-generated and "make clean" is executed (to make sure everything is fresh).
it is automatic and should be seemless with the current build.


From the developer's POV, it works like this:

1. If you use "git tag" to tag a new version, the new tag will be the version string.
example:
Before the next release, once you're happy with the changes, run:
$ git tag v2.16.0
$ make

and "version.h" will contain "v2.16.0".

2. If (after tagging) you had three more commits, the automatic version will be:
"v2.16.0-3-1acf45a"
This will make it very easy to know I'm using a modified (post-released) version, and even the exact revision.

3. If (after tagging) you made changes that are not yet committed (as part of development), the version string will be:
"v.2.16.0-3-1acf45a-dirty"
Indicating that this is a modified version.

4. If you don't use tags, the version will simply be the last commit (ugly, so better use git tags).


This way, when users now report errors, you can ask for the version string and know exactly what are they using.


Regards,
-gordon

Aaron Quinlan

unread,
Feb 17, 2012, 10:14:57 AM2/17/12
to bedtools...@googlegroups.com
Hi Gordon,

Thanks for this fantastic contribution. I've been meaning to do something like this, but was a bit unsure of the best way to do it. Your solution seems like a good one, so I have integrated your changes.

Many thanks,
Aaron

Reply all
Reply to author
Forward
0 new messages