views:

94

answers:

2
+1  Q: 

Obtaining version

I'm a sole developer, using GIT for version-control of embedded software written in C. The software needs to be aware of it's version, and it's currently done by including a header file with a single #define:

#define SOFTWARE_VERSION "1.021"

This header file is automatically created by pre-build Python script that tries to obtain the latest tag form GIT repository (I tag all released versions with current version string). This is the command I use to obtain last version string.

git describe --tag HEAD

The whole chain works as expected, but it doesn't seem robust (I expect it to break as repository gets more complicated/branched). Also, I think I might be missing something crucial, as there's got to be easier way to do this.

Can anyone offer improvements on workflow or implementation details? (if anyone's interested, I can post python script that parses the output of git describe)

+2  A: 

Separate the software release version number from the CM system version number.

Yes, you need to know the version or tag in the CM system that corresponds to a given release number, but don't use the CM system version number to define the release number.

With simple VCS like RCS or SCCS, and with simple (one file) programs, you can use the VCS to provide the program version - I do that myself. But all my complex programs use a completely separate version numbering scheme, wholly divorced from the version numbers in the VCS.

Jonathan Leffler
Yes, use your pre-build script to *write* the tag on your repo with a release number that you calculate or enter.
Paul
I'm not using CM version to define release number. I place the tag by hand, and it has nothing to do with CM commit identifier. By using the git describe, I can get the last tag, but I'm not happy with output that needs to be parsed to be useful. It feels like a hack...
Josip
A: 

As mention in this SO question, git describe could be what you need to reference an intermediate "version" which is both:

  • based on the latest applicative version (i.e. 'tag')
  • based on the internal commit (i.e. sha1)
VonC