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

This commit is contained in:
Jenkins 2014-02-28 17:30:35 +00:00 committed by Gerrit Code Review
commit 3208d7ad43

View File

@ -1225,14 +1225,12 @@ function pip_install {
function setup_develop {
local project_dir=$1
echo "cd $REQUIREMENTS_DIR; $SUDO_CMD python update.py $project_dir"
# Don't update repo if local changes exist
# Don't use buggy "git diff --quiet"
(cd $project_dir && git diff --exit-code >/dev/null)
local update_requirements=$?
# ``errexit`` requires us to trap the exit code when the repo is changed
local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed")
if [ $update_requirements -eq 0 ]; then
if [[ $update_requirements = "changed" ]]; then
(cd $REQUIREMENTS_DIR; \
$SUDO_CMD python update.py $project_dir)
fi
@ -1248,7 +1246,7 @@ function setup_develop {
# a variable that tells us whether or not we should UNDO the requirements
# changes (this will be set to False in the OpenStack ci gate)
if [ $UNDO_REQUIREMENTS = "True" ]; then
if [ $update_requirements -eq 0 ]; then
if [[ $update_requirements = "changed" ]]; then
(cd $project_dir && git reset --hard)
fi
fi