clean-up
[tomato/davidwu.git] / toolchain / scripts / getver.sh
blob82fe62b189230f32c4cefd2e31b99636f3f9e70b
1 #!/usr/bin/env bash
2 export LANG=C
3 export LC_ALL=C
4 [ -n "$TOPDIR" ] && cd $TOPDIR
6 try_version() {
7 [ -f version ] || return 1
8 REV="$(cat version)"
9 [ -n "$REV" ]
12 try_svn() {
13 [ -d .svn ] || return 1
14 REV="$(svn info | awk '/^Revision:/ { print $2 }')"
15 REV="${REV:+r$REV}"
16 [ -n "$REV" ]
19 try_git() {
20 [ -d .git ] || return 1
21 REV="$(git-log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "", $2); print $2 }')"
22 REV="${REV:+r$REV}"
23 [ -n "$REV" ]
26 try_version || try_svn || try_git || REV="unknown"
27 echo "$REV"