09-07-2011, 10:46 PM
Both are impossible to do without checking out the git repository. The first one MIGHT be possible via the google code api, you'd have to write a custom script for that, though...
#!/bin/bash
git rev-list HEAD | sort > config.git-hash
LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
if [ $LOCALVER \> 1 ] ; then
VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'`
if [ $VER != $LOCALVER ] ; then
VER="$VER+$(($LOCALVER-$VER))"
fi
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7)"
echo "#define X264_VERSION \" r$VER\""
else
echo "#define X264_VERSION \"\""
VER="x"
fi
rm -f config.git-hash
API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'`
echo "#define X264_POINTVER \"0.$API.$VER\""
(09-09-2011, 06:11 AM)imk Wrote: [ -> ]For getting a revision number, x264 uses this script:This script assumes you are running it from within a directory controlled by git (it is meant to be checked into a repository).
Code:
#!/bin/bash
git rev-list HEAD | sort > config.git-hash
LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
if [ $LOCALVER \> 1 ] ; then
VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'`
if [ $VER != $LOCALVER ] ; then
VER="$VER+$(($LOCALVER-$VER))"
fi
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7)"
echo "#define X264_VERSION \" r$VER\""
else
echo "#define X264_VERSION \"\""
VER="x"
fi
rm -f config.git-hash
API=`grep '#define X264_BUILD' < x264.h | sed -e 's/.* \([1-9][0-9]*\).*/\1/'`
echo "#define X264_POINTVER \"0.$API.$VER\""
It's a shell script, but the commands used are obvious. This could be reworked to work on all supported platforms.
The revision number itself is basically a sum of the commits. It's not quite the same as an actual revision number and it should be used alongside a git hash.
When running "x264 --version" this output is provided:
x264 0.116.2037 f8ebd4a
The revision number is 2037 and the first 8 characters of the hash are provided.
(09-09-2011, 11:05 AM)shuffle2 Wrote: [ -> ]This script assumes you are running it from within a directory controlled by git (it is meant to be checked into a repository).
