[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Generating version numbers from files not tags, in mixed svn / git-svn e

From: Raphael 'kena' Poss
Subject: Generating version numbers from files not tags, in mixed svn / git-svn environments
Date: Sat, 26 Dec 2009 13:57:47 +0100

Hi all,

I would like to submit the attached script to your collective attention. This 
is a helper script to automate handling project version numbers in a mixed 
autoconf / svn / git-svn environment.

Some context: I work in an environment where source code is primarily stored in 
and distributed from Subversion repositories, but where several developers 
maintain local git clones using git-svn. We were interested to generate 
automatically and use version numbers in our code that are meaningful; `git 
describe' and `git-version-gen' were inspiring but we are working under 
different assumptions:

- version numbers are derived from the content of a file, not the name of a tag 
in the SCM repository;

- versions numbers must be meaningful even for people working directly using 
svn (i.e. without git);

- we are privileging svn revision numbers over git hashes: when compiling from 
a git-svn branch and the last commit was produced by `git-svn dcommit', we 
prefer to use the corresponding svn version number.

Hence the attached script, similar in use and purpose as `git-version-gen' but 
implemented entirely differently to support Subversion primarily instead (and 
git hashes as a fallback). Like git-version-gen the top of the script contains 
documentation, examples and how-to-use instructions.

From this point I have a few questions:

- would you have any suggestions as to the portability of this script? Despite 
the explicit mention of "/bin/bash" at the top I think very few bashisms are 
being in use and I would welcome trying to get rid of them.

- the way I currently use this with Automake is as follows, which I find 
simpler than the GNUmakefile approach used by M4, Bison and others:

  ## Version number management
  EXTRA_DIST = .version
  BUILT_SOURCES = $(top_srcdir)/.version
        echo $(VERSION) >address@hidden && mv address@hidden $@
  dist-hook: check-version
        echo $(VERSION) >$(distdir)/build-aux/tarball-version
  install-exec-am install-data-am installcheck-am: check-version
  VERSION_GEN = (cd $(top_srcdir); build-aux/version-gen \
        build-aux/tarball-version build-aux/package-version)
  .PHONY: check-version _version
        set -e; \
        if ! test "x$(VERSION)" = "x`$(VERSION_GEN)`"; then \
           echo "Version string not up to date: run 'make _version' first." 
>&2; \
           exit 1; \
        cd $(srcdir) && rm -rf autom4te.cache .version && 

Do you have any comments about this approach? Any criticisms or suggested 

Best regards,

-- k

Attachment: version-gen
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]