wmakePrintBuild - cd first, so we get the correct git information

This commit is contained in:
Mark Olesen
2009-08-02 11:06:26 +02:00
parent 41b196ffeb
commit 7fb61ed941

View File

@ -27,15 +27,13 @@
# wmakePrintBuild # wmakePrintBuild
# #
# Description # Description
# Print the version used when building the project. # Print the version used when building the project
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Script=${0##*/}
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: $Script [OPTION] usage: ${0##*/} [OPTION]
options: options:
-check check the git head commit vs. \$WM_PROJECT_DIR/.build -check check the git head commit vs. \$WM_PROJECT_DIR/.build
(exit code 0 for no changes) (exit code 0 for no changes)
@ -76,7 +74,7 @@ do
;; ;;
-v | -version) -v | -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
version=$2 version="$2"
shift 2 shift 2
;; ;;
*) *)
@ -101,7 +99,10 @@ else
# get the head SHA1 when building under git # get the head SHA1 when building under git
# if there are multiple values (eg, HEAD, origin/HEAD, ...) # if there are multiple values (eg, HEAD, origin/HEAD, ...)
# only take the first one, which is 'HEAD' # only take the first one, which is 'HEAD'
version=$(git show-ref --hash=12 --head HEAD 2>/dev/null | head -1) version=$(
cd $WM_PROJECT_DIR 2>/dev/null && \
git show-ref --hash=12 --head HEAD 2>/dev/null | head -1
)
if [ -n "$version" ] if [ -n "$version" ]
then then