Discussion:
Generating version numbers from files not tags, in mixed svn / git-svn environments
Raphael 'kena' Poss
2009-12-26 12:57:47 UTC
Permalink
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

$(top_srcdir)/.version:
echo $(VERSION) >$@-t && mv $@-t $@

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
check-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; \
fi

_version:
cd $(srcdir) && rm -rf autom4te.cache .version && $${AUTORECONF:-autoreconf}


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

Best regards,

-- k
Rhys Ulerich
2014-03-20 05:12:53 UTC
Permalink
Hi Raphael,

(Resurrecting: https://lists.gnu.org/archive/html/autoconf/2009-12/msg00056.html)
Post by Raphael 'kena' Poss
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.
This looks like exactly what I need for a project. Thank you for
throwing it out on the mailing list. Did anything further ever come
of the script?

Thanks,
Rhys
Rhys Ulerich
2014-06-19 18:02:27 UTC
Permalink
YMMV.
My mileage has been great thus far in a mixed git/svn environment.
Thank you for the useful tool.

- Rhys
a***@raphael.poss.name
2014-06-19 17:14:38 UTC
Permalink
Hi Rhys, all,

this script has been used successfully in production since then,
although now SVN has nearly disappeared from said production
environment.

I did not receive any further comment since 2009, although no complaints
either.

YMMV.
Post by Rhys Ulerich
Hi Raphael,
https://lists.gnu.org/archive/html/autoconf/2009-12/msg00056.html)
Post by Raphael 'kena' Poss
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.
This looks like exactly what I need for a project. Thank you for
throwing it out on the mailing list. Did anything further ever come
of the script?
Thanks,
Rhys
Loading...