diff options
author | Lukas Larsson <[email protected]> | 2013-01-31 17:10:32 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2013-02-13 16:05:58 +0100 |
commit | 3e95d5f8e4a348efbb8fb1036da3fa9368c75ae2 (patch) | |
tree | ab0f23aaf36cb6387e105984da9fb58063099fdf /erts/emulator/utils/gen_git_version | |
parent | 68b804f34d4ec420d86953e3f519179a40fbee8f (diff) | |
download | otp-3e95d5f8e4a348efbb8fb1036da3fa9368c75ae2.tar.gz otp-3e95d5f8e4a348efbb8fb1036da3fa9368c75ae2.tar.bz2 otp-3e95d5f8e4a348efbb8fb1036da3fa9368c75ae2.zip |
Include git sha in prompt if available
The sha will only be included if there is no tag
starting with OTP_R* associated with the sha. This
is because we do not want the sha to show on offical
releases.
Diffstat (limited to 'erts/emulator/utils/gen_git_version')
-rwxr-xr-x | erts/emulator/utils/gen_git_version | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/erts/emulator/utils/gen_git_version b/erts/emulator/utils/gen_git_version new file mode 100755 index 0000000000..d93a97cbbb --- /dev/null +++ b/erts/emulator/utils/gen_git_version @@ -0,0 +1,40 @@ +#!/bin/sh + +OUTPUT_FILE=$1 + +if command -v git 2>&1 >/dev/null && + test -d $ERL_TOP/.git -o -f $ERL_TOP/.git +then + VSN=`git describe --match "OTP_R[0-9][0-9][A-B]*" HEAD` + case "$VSN" in + OTP_R*-g*) + VSN=`echo $VSN | sed -e 's/.*-g\\(.*\\)/\\1/g'` ;; + *) VSN="na" ;; + esac +else + VSN="na" +fi + + +# Only update the file if there has been a change to +# the version number. +if test -r $OUTPUT_FILE +then + VC=`sed -n -e 's/^.*"\\\\"\\(.*\\)\\\\"".*/\\1/p' < $OUTPUT_FILE` +else + VC=unset +fi +echo "VSN = $VSN" +echo "VC = $VC" +if test "$VSN" != "$VC" +then + echo "# Automatically generated by $0 - DO NOT EDIT." > $OUTPUT_FILE + if test "$VSN" = "na" + then + echo "# GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE + else + echo "GIT_VSN=-DERLANG_GIT_VERSION=\"\\\"$VSN\\\"\"" >> $OUTPUT_FILE + fi + exit 0 +fi +exit 1
\ No newline at end of file |