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
... | ... |
@@ -142,6 +142,8 @@ GetOSVersion() { |
142 | 142 |
# be owned by the installation user, we create the directory and change the |
143 | 143 |
# ownership to the proper user. |
144 | 144 |
# 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). |
|
145 | 147 |
# git_clone remote dest-dir branch |
146 | 148 |
function git_clone { |
147 | 149 |
[[ "$OFFLINE" = "True" ]] && return |
... | ... |
@@ -153,6 +155,7 @@ function git_clone { |
153 | 153 |
if echo $GIT_BRANCH | egrep -q "^refs"; then |
154 | 154 |
# If our branch name is a gerrit style refs/changes/... |
155 | 155 |
if [[ ! -d $GIT_DEST ]]; then |
156 |
+ [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1 |
|
156 | 157 |
git clone $GIT_REMOTE $GIT_DEST |
157 | 158 |
fi |
158 | 159 |
cd $GIT_DEST |
... | ... |
@@ -160,6 +163,7 @@ function git_clone { |
160 | 160 |
else |
161 | 161 |
# do a full clone only if the directory doesn't exist |
162 | 162 |
if [[ ! -d $GIT_DEST ]]; then |
163 |
+ [[ "$ERROR_ON_CLONE" = "True" ]] && exit 1 |
|
163 | 164 |
git clone $GIT_REMOTE $GIT_DEST |
164 | 165 |
cd $GIT_DEST |
165 | 166 |
# This checkout syntax works for both branches and tags |
... | ... |
@@ -214,6 +214,11 @@ fi |
214 | 214 |
# prerequisites and initialize ``$DEST``. |
215 | 215 |
OFFLINE=`trueorfalse False $OFFLINE` |
216 | 216 |
|
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 |
+ |
|
217 | 222 |
# Destination path for service data |
218 | 223 |
DATA_DIR=${DATA_DIR:-${DEST}/data} |
219 | 224 |
sudo mkdir -p $DATA_DIR |