[PATCH v1 1/1] tests: add Git submodule version consistency test

John Keeping john at keeping.me.uk
Tue Mar 19 12:26:52 CET 2013


On Tue, Mar 19, 2013 at 12:10:45PM +0100, Ferry Huberts wrote:
> 
> 
> On 19/03/13 11:43, John Keeping wrote:
> > On Tue, Mar 19, 2013 at 01:01:45AM +0100, Ferry Huberts wrote:
> >> From: Ferry Huberts <ferry.huberts at pelagic.nl>
> >>
> >> To ensure the versions are in sync
> > I like the idea of this, but I think we should be able to get away with
> > something much simpler like this:
> >
> > run_test 'Git versions are consistent' '
> > 	( cd ../git && git describe || echo "No submodule!" ) >tmp/sm_version &&
> > 	sed -n -e "/^GIT_VER[ 	]*=/ {
> > 		s/^GIT_VER[ 	]*=[ 	]*//
> > 		p
> > 	}" >tmp/make_version &&
> > 	diff -u tmp/sm_version tmp/make_version
> > '
> >
> 
> 
> Did you test this?
> Because the submodule SHA points to the commit, not to the tag.

That's why I use "git describe" which will work in this scenario.  Of
course, this doesn't check the submodule version that's committed, just
what is checked out in ./git, but thinking about it I'm not sure if
that's actually a bad thing because it will let the tests run even when
someone is checking a Git update and it will point out a not-up-to-date
submodule anyway.

What I did miss is stripping the initial "v" from the version returned
by git-describe, so I think it can be made more robust by doing this
(tested this time, so I've also fixed "tmp -> trash" and missing
argument to sed):

run_test 'Git versions are consistent' '
	(
		cd ../git &&
		git describe --match "v[0-9]*" || echo "No submodule!"
	) | sed -e "s/^v//" >trash/sm_version &&
	sed -n -e "/^GIT_VER[ 	]*=/ {
		s/^GIT_VER[ 	]*=[ 	]*//
		p
	}" ../Makefile >trash/make_version &&
	diff -u trash/sm_version trash/make_version
'


John




More information about the CGit mailing list