diff options
author | 2010-01-24 14:33:28 +0100 | |
---|---|---|
committer | 2010-01-24 14:33:28 +0100 | |
commit | 27b23bc15985aea687aecec580d668b7f9701eb3 (patch) | |
tree | b82659a8350c09d85e85e74af639ee909892d37e /misc/hash.sh | |
parent | 6d4547a49805b552e9b56d41a653a0912e7b0534 (diff) | |
parent | c8fb24d1069aa776bccdf3141adb9d3c3f6e8101 (diff) |
merge in experimental
Diffstat (limited to 'misc/hash.sh')
-rwxr-xr-x | misc/hash.sh | 25 |
1 files changed, 25 insertions, 0 deletions
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 <hash/tag>` (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 |