| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
export LANG=C |
| 4 |
export LC_MESSAGES=C |
| 5 |
export LC_ALL=C |
| 6 |
|
| 7 |
# meant to be run with CP2K's src dir as first argument |
| 8 |
|
| 9 |
if [ -s "$1/../REVISION" ] ; then |
| 10 |
cat "$1/../REVISION" |
| 11 |
exit 0 |
| 12 |
fi |
| 13 |
|
| 14 |
GIT_DIR="$1/../.git" |
| 15 |
GIT_HEAD="${GIT_DIR}/HEAD" |
| 16 |
|
| 17 |
if [ ! -s "${GIT_HEAD}" ] ; then |
| 18 |
echo "unknown revision" |
| 19 |
>&2 echo "WARNING: $0 failed to determine the Git commit and no REVISION file available" |
| 20 |
exit 1 |
| 21 |
fi |
| 22 |
|
| 23 |
REF="`awk '{print $2}' "${GIT_HEAD}"`" |
| 24 |
|
| 25 |
# if there is no second column, then we're in a detached HEAD |
| 26 |
# and the file contains the revision |
| 27 |
if [ -z "${REF}" ] ; then |
| 28 |
echo "git:`head -c 7 "${GIT_HEAD}"`" |
| 29 |
else |
| 30 |
echo "git:`head -c 7 "${GIT_DIR}/${REF}"`" |
| 31 |
fi |