diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2009-12-20 17:42:09 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-12-20 17:42:09 +0100 |
commit | 276e7fc2f9d6423a0771aae7b918731d30e96b7d (patch) | |
tree | 1b750b27595c24d8b626a7180637b4991c520bb0 /hash.sh | |
parent | 14cf5ea1473411c436728b5464043336322a767b (diff) |
proper commit hash setting
Diffstat (limited to 'hash.sh')
-rwxr-xr-x[-rw-r--r--] | hash.sh | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -1,3 +1,25 @@ #!/bin/sh # script to determine git hash of current source tree -FROM_ARCHIVE=$Format:%H$ # set when running git --archive <hash/tag>
\ No newline at end of file + +# 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 |