Add ERROR_ON_CLONE.

This lets the user assert that stack.sh should never need to clone
any git repositories.  If set to True, and devstack does need to
clone a git repo, stack.sh will exit with an error.

This is useful in testing environments to make sure that the correct
code is being tested instead of silently falling back on cloning
from the public repos.

Change-Id: Ic0312ab4df492c5cf2e04c08aa7669a81736daa6
This commit is contained in:
James E. Blair 2012-06-22 15:28:29 -07:00
parent 8d2c8faf36
commit 94cb960009
2 changed files with 9 additions and 0 deletions

View File

@ -142,6 +142,8 @@ GetOSVersion() {
# be owned by the installation user, we create the directory and change the # be owned by the installation user, we create the directory and change the
# ownership to the proper user. # ownership to the proper user.
# Set global RECLONE=yes to simulate a clone when dest-dir exists # Set global RECLONE=yes to simulate a clone when dest-dir exists
# Set global ERROR_ON_CLONE=True to abort execution with an error if the git repo
# does not exist (default is False, meaning the repo will be cloned).
# git_clone remote dest-dir branch # git_clone remote dest-dir branch
function git_clone { function git_clone {
[[ "$OFFLINE" = "True" ]] && return [[ "$OFFLINE" = "True" ]] && return
@ -153,6 +155,7 @@ function git_clone {
if echo $GIT_BRANCH | egrep -q "^refs"; then if echo $GIT_BRANCH | egrep -q "^refs"; then
# If our branch name is a gerrit style refs/changes/... # If our branch name is a gerrit style refs/changes/...
if [[ ! -d $GIT_DEST ]]; then if [[ ! -d $GIT_DEST ]]; then
[[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
git clone $GIT_REMOTE $GIT_DEST git clone $GIT_REMOTE $GIT_DEST
fi fi
cd $GIT_DEST cd $GIT_DEST
@ -160,6 +163,7 @@ function git_clone {
else else
# do a full clone only if the directory doesn't exist # do a full clone only if the directory doesn't exist
if [[ ! -d $GIT_DEST ]]; then if [[ ! -d $GIT_DEST ]]; then
[[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
git clone $GIT_REMOTE $GIT_DEST git clone $GIT_REMOTE $GIT_DEST
cd $GIT_DEST cd $GIT_DEST
# This checkout syntax works for both branches and tags # This checkout syntax works for both branches and tags

View File

@ -214,6 +214,11 @@ fi
# prerequisites and initialize ``$DEST``. # prerequisites and initialize ``$DEST``.
OFFLINE=`trueorfalse False $OFFLINE` OFFLINE=`trueorfalse False $OFFLINE`
# Set True to configure ``stack.sh`` to exit with an error code if it is asked
# to clone any git repositories. If devstack is used in a testing environment,
# this may be used to ensure that the correct code is being tested.
ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
# Destination path for service data # Destination path for service data
DATA_DIR=${DATA_DIR:-${DEST}/data} DATA_DIR=${DATA_DIR:-${DEST}/data}
sudo mkdir -p $DATA_DIR sudo mkdir -p $DATA_DIR