I want to introduce a versioning constant grabbed from the version in Git. I know how to do this -- in a very hackish way in svn --
any ideas on how to do this with
Instead of putting it in a text file then getting the contents of it each time, this appears to work quite well:
sed -i.bak "s/$version = '.*';/$version = '`git rev-parse --short HEAD | tr -d '\n'`';/g" version.php
where version.php looks like this:
and then just include the file in your script as you would a settings file.
You could also use git describe --all --long
as your version string if you wanted to, I preferred the git-hash from git-ref-parse --short HEAD
for my purposes.
Or as a constant which may be better:
sed -i.bak "s/define('VERSION','.*');/define('VERSION','`git describe --all --long | cut -d "-" -f 3`');/g" version.php
and version.php: