From: Kacper Kornet Date: Sat, 11 Jun 2011 20:36:52 +0000 (+0100) Subject: Move check which branch is active to init_builder X-Git-Tag: auto/th/rpm-build-tools-4.5-3~23 X-Git-Url: http://git.pld-linux.org/?a=commitdiff_plain;h=a095de80eefe2e412fb402053b19951fcab537f7;p=packages%2Frpm-build-tools.git Move check which branch is active to init_builder To check which branch is active the proper GIT_DIR is required, which is set in init_builder. --- diff --git a/builder.sh b/builder.sh index e0c7fb5..5dc7b53 100755 --- a/builder.sh +++ b/builder.sh @@ -747,6 +747,21 @@ init_builder() { export GIT_WORK_TREE=$PACKAGE_DIR export GIT_DIR=$PACKAGE_DIR/.git + if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then + if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then + CVSTAG=${CVSTAG#refs/heads/} + if [ "$CVSTAG" != "master" ]; then + echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override" + fi + else + echo >&2 "On detached HEAD. Use -r BRANCHNAME to override" + HEAD_DETACHED="yes" + fi + elif [ "$CVSTAG" = "HEAD" ]; then + # assume -r HEAD is same as -A + CVSTAG="master" + fi + __PWD=$(pwd) } @@ -2267,22 +2282,6 @@ while [ $# -gt 0 ]; do esac done -[ -d "$ASSUMED_NAME" ] && GIT_DIR="$ASSUMED_NAME/.git" || GIT_DIR=.git -if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then - if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then - CVSTAG=${CVSTAG#refs/heads/} - if [ "$CVSTAG" != "master" ]; then - echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override" - fi - else - echo >&2 "On detached HEAD. Use -r BRANCHNAME to override" - HEAD_DETACHED="yes" - fi -elif [ "$CVSTAG" = "HEAD" ]; then - # assume -r HEAD is same as -A - CVSTAG="master" -fi - if [ "$CVSTAG" ]; then # pass $CVSTAG used by builder to rpmbuild too, so specs could use it RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""