diff options
Diffstat (limited to 'src/version.bash')
| -rwxr-xr-x | src/version.bash | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/version.bash b/src/version.bash index ce5a9969a..fc899e2e3 100755 --- a/src/version.bash +++ b/src/version.bash @@ -3,9 +3,18 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -# Check that we can use 'hg' -if ! hg version > /dev/null 2>&1; then - echo 'hg not installed' 1>&2 +GOROOT=$(dirname $0)/.. + +# If a version file created by -save is available, use it +if [ -f "$GOROOT/VERSION" ]; then + cat $GOROOT/VERSION + exit 0 +fi + +# Otherwise, if hg doesn't work for whatever reason, fail +if [ ! -d "$GOROOT/.hg" ] || ! hg version > /dev/null 2>&1; then + echo 'Unable to report version: hg and VERSION file missing' 1>&2 + echo 'Generate VERSION with `src/version.bash -save` while hg is usable' 1>&2 exit 2 fi @@ -34,5 +43,8 @@ if [ "$TAG" != "" ]; then VERSION="$TAG $VERSION" fi -echo $VERSION - +if [ "$1" = "-save" ]; then + echo $VERSION > $GOROOT/VERSION +else + echo $VERSION +fi |
