Skip to content

Commit 94cb960

Browse files
committed
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
1 parent 8d2c8fa commit 94cb960

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

functions

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ GetOSVersion() {
142142
# be owned by the installation user, we create the directory and change the
143143
# ownership to the proper user.
144144
# Set global RECLONE=yes to simulate a clone when dest-dir exists
145+
# Set global ERROR_ON_CLONE=True to abort execution with an error if the git repo
146+
# does not exist (default is False, meaning the repo will be cloned).
145147
# git_clone remote dest-dir branch
146148
function git_clone {
147149
[[ "$OFFLINE" = "True" ]] && return
@@ -153,13 +155,15 @@ function git_clone {
153155
if echo $GIT_BRANCH | egrep -q "^refs"; then
154156
# If our branch name is a gerrit style refs/changes/...
155157
if [[ ! -d $GIT_DEST ]]; then
158+
[[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
156159
git clone $GIT_REMOTE $GIT_DEST
157160
fi
158161
cd $GIT_DEST
159162
git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD
160163
else
161164
# do a full clone only if the directory doesn't exist
162165
if [[ ! -d $GIT_DEST ]]; then
166+
[[ "$ERROR_ON_CLONE" = "True" ]] && exit 1
163167
git clone $GIT_REMOTE $GIT_DEST
164168
cd $GIT_DEST
165169
# This checkout syntax works for both branches and tags

stack.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ fi
214214
# prerequisites and initialize ``$DEST``.
215215
OFFLINE=`trueorfalse False $OFFLINE`
216216

217+
# Set True to configure ``stack.sh`` to exit with an error code if it is asked
218+
# to clone any git repositories. If devstack is used in a testing environment,
219+
# this may be used to ensure that the correct code is being tested.
220+
ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
221+
217222
# Destination path for service data
218223
DATA_DIR=${DATA_DIR:-${DEST}/data}
219224
sudo mkdir -p $DATA_DIR

0 commit comments

Comments
 (0)