Normalise RECLONE flag to True Or False.

RECLONE flag now uses function trueorfalse for flag handling.
Added more flag cases to normalisation function trueorfalse.

Fixes bug #1200382

Change-Id: I0738537c87634281c6a92fa93b7f84a6b0dad497
This commit is contained in:
Sirushti Murugesan 2013-09-25 11:30:31 +05:30
parent 23033e0399
commit a8d41e3af7

View File

@ -551,6 +551,7 @@ function git_clone {
GIT_REMOTE=$1 GIT_REMOTE=$1
GIT_DEST=$2 GIT_DEST=$2
GIT_REF=$3 GIT_REF=$3
RECLONE=$(trueorfalse False $RECLONE)
if [[ "$OFFLINE" = "True" ]]; then if [[ "$OFFLINE" = "True" ]]; then
echo "Running in offline mode, clones already exist" echo "Running in offline mode, clones already exist"
@ -576,7 +577,7 @@ function git_clone {
cd $GIT_DEST cd $GIT_DEST
# This checkout syntax works for both branches and tags # This checkout syntax works for both branches and tags
git checkout $GIT_REF git checkout $GIT_REF
elif [[ "$RECLONE" == "yes" ]]; then elif [[ "$RECLONE" = "True" ]]; then
# if it does exist then simulate what clone does if asked to RECLONE # if it does exist then simulate what clone does if asked to RECLONE
cd $GIT_DEST cd $GIT_DEST
# set the url to pull from and fetch # set the url to pull from and fetch
@ -1260,16 +1261,16 @@ function stop_service() {
# Normalize config values to True or False # Normalize config values to True or False
# Accepts as False: 0 no false False FALSE # Accepts as False: 0 no No NO false False FALSE
# Accepts as True: 1 yes true True TRUE # Accepts as True: 1 yes Yes YES true True TRUE
# VAR=$(trueorfalse default-value test-value) # VAR=$(trueorfalse default-value test-value)
function trueorfalse() { function trueorfalse() {
local default=$1 local default=$1
local testval=$2 local testval=$2
[[ -z "$testval" ]] && { echo "$default"; return; } [[ -z "$testval" ]] && { echo "$default"; return; }
[[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; } [[ "0 no No NO false False FALSE" =~ "$testval" ]] && { echo "False"; return; }
[[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; } [[ "1 yes Yes YES true True TRUE" =~ "$testval" ]] && { echo "True"; return; }
echo "$default" echo "$default"
} }