From a2ddc36070d9478d3a75e3aa80760e4016ba59d2 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 1 Jan 2010 18:14:22 +0100 Subject: hash.sh -> misc/hash.sh --- misc/hash.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 misc/hash.sh (limited to 'misc') diff --git a/misc/hash.sh b/misc/hash.sh new file mode 100755 index 0000000..0c97722 --- /dev/null +++ b/misc/hash.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# script to determine git hash of current source tree + +# set a variable when running `git --archive ` (this is what github does) +# alternatively, you could also git get-tar-commit-id < tarball (but that's a bit dirtier) +FROM_ARCHIVE=$Format:%H$ + +# ... but try to use whatever git tells us if there is a .git folder +if [ -d .git -a -r .git ] +then + hash=$(git log 2>/dev/null | head -n1 2>/dev/null | sed "s/.* //" 2>/dev/null) +fi + +if [ x"$hash" != x ] +then + echo $hash +elif [ "$FROM_ARCHIVE" != ':%H$' ] +then + echo $FROM_ARCHIVE +else + echo "commit hash detection fail. Dear packager, please figure out what goes wrong or get in touch with us" >&2 + echo UNKNOWN + exit 2 +fi +exit 0 -- cgit v1.2.3