The check for a changed repo in setup_develop() 'git diff --exit-code'
returns a status of 1 when the repo has changes; trap that so errexit
does not abort the script.
Bug-Id: 1285780
Change-Id: Ic97e68348f46245b271567893b447fcedbd7bd6e
| ... | ... |
@@ -1223,14 +1223,12 @@ function pip_install {
|
| 1223 | 1223 |
function setup_develop() {
|
| 1224 | 1224 |
local project_dir=$1 |
| 1225 | 1225 |
|
| 1226 |
- echo "cd $REQUIREMENTS_DIR; $SUDO_CMD python update.py $project_dir" |
|
| 1227 |
- |
|
| 1228 | 1226 |
# Don't update repo if local changes exist |
| 1229 | 1227 |
# Don't use buggy "git diff --quiet" |
| 1230 |
- (cd $project_dir && git diff --exit-code >/dev/null) |
|
| 1231 |
- local update_requirements=$? |
|
| 1228 |
+ # ``errexit`` requires us to trap the exit code when the repo is changed |
|
| 1229 |
+ local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed") |
|
| 1232 | 1230 |
|
| 1233 |
- if [ $update_requirements -eq 0 ]; then |
|
| 1231 |
+ if [[ $update_requirements = "changed" ]]; then |
|
| 1234 | 1232 |
(cd $REQUIREMENTS_DIR; \ |
| 1235 | 1233 |
$SUDO_CMD python update.py $project_dir) |
| 1236 | 1234 |
fi |
| ... | ... |
@@ -1246,7 +1244,7 @@ function setup_develop() {
|
| 1246 | 1246 |
# a variable that tells us whether or not we should UNDO the requirements |
| 1247 | 1247 |
# changes (this will be set to False in the OpenStack ci gate) |
| 1248 | 1248 |
if [ $UNDO_REQUIREMENTS = "True" ]; then |
| 1249 |
- if [ $update_requirements -eq 0 ]; then |
|
| 1249 |
+ if [[ $update_requirements = "changed" ]]; then |
|
| 1250 | 1250 |
(cd $project_dir && git reset --hard) |
| 1251 | 1251 |
fi |
| 1252 | 1252 |
fi |