Browse code

Merge "Handle non-zero exit code from git diff"

Jenkins authored on 2014/03/01 02:30:35
Showing 1 changed files
... ...
@@ -1225,14 +1225,12 @@ function pip_install {
1225 1225
 function setup_develop {
1226 1226
     local project_dir=$1
1227 1227
 
1228
-    echo "cd $REQUIREMENTS_DIR; $SUDO_CMD python update.py $project_dir"
1229
-
1230 1228
     # Don't update repo if local changes exist
1231 1229
     # Don't use buggy "git diff --quiet"
1232
-    (cd $project_dir && git diff --exit-code >/dev/null)
1233
-    local update_requirements=$?
1230
+    # ``errexit`` requires us to trap the exit code when the repo is changed
1231
+    local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed")
1234 1232
 
1235
-    if [ $update_requirements -eq 0 ]; then
1233
+    if [[ $update_requirements = "changed" ]]; then
1236 1234
         (cd $REQUIREMENTS_DIR; \
1237 1235
             $SUDO_CMD python update.py $project_dir)
1238 1236
     fi
... ...
@@ -1248,7 +1246,7 @@ function setup_develop {
1248 1248
     # a variable that tells us whether or not we should UNDO the requirements
1249 1249
     # changes (this will be set to False in the OpenStack ci gate)
1250 1250
     if [ $UNDO_REQUIREMENTS = "True" ]; then
1251
-        if [ $update_requirements -eq 0 ]; then
1251
+        if [[ $update_requirements = "changed" ]]; then
1252 1252
             (cd $project_dir && git reset --hard)
1253 1253
         fi
1254 1254
     fi