From bd12fb6b643920a4bfbb3a9c2634f3ebae06cf0e Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 23 Jun 2020 06:33:43 +0800 Subject: [PATCH] tools/version.sh: Make it invokable from everywhere Signed-off-by: Xiang Xiao --- tools/version.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/version.sh b/tools/version.sh index d5574d318a..8467cbd133 100755 --- a/tools/version.sh +++ b/tools/version.sh @@ -32,7 +32,7 @@ # POSSIBILITY OF SUCH DAMAGE. # -WD=`pwd` +WD=$(dirname $0) # Get command line parameters @@ -86,7 +86,7 @@ done OUTFILE=$1 if [ -z ${VERSION} ] ; then - VERSION=`git tag --sort=taggerdate | tail -1 | cut -d'-' -f2` + VERSION=`git -C ${WD} tag --sort=taggerdate | tail -1 | cut -d'-' -f2` # Earlier tags used the format "major.minor", append a "0" for a patch. @@ -133,12 +133,12 @@ PATCH=`echo ${VERSION} | cut -d'.' -f3` # Get GIT information (if not provided on the command line) if [ -z "${BUILD}" ]; then - BUILD=`git log --oneline -1 | cut -d' ' -f1 2>/dev/null` + BUILD=`git -C ${WD} log --oneline -1 | cut -d' ' -f1 2>/dev/null` if [ -z "${BUILD}" ]; then echo "GIT version information is not available" exit 5 fi - if [ -n "`git diff-index --name-only HEAD | head -1`" ]; then + if [ -n "`git -C ${WD} diff-index --name-only HEAD | head -1`" ]; then BUILD=${BUILD}-dirty fi fi