Make requirement update proposals more robust.

When proposing requirement update changes ensure that the proper branch
can be checked out if the branch isn't master. To do this checkout
origin/$BRANCH instead of just branch. Additonally, don't git review -d
an existing change as it may have merge conflicts with the target
branch. Instead make changes against the target branch, push them to the
existing change as a new patchset, and ignore failures of git review
when there are no new changes.

This allows changes to the requirements files to happen out of band from
these automated change proposals.

Closes-Bug: 1274251
Change-Id: I7b81b87a90639a66dce5502cded5e37d96abd1f7
This commit is contained in:
Clark Boylan 2014-01-29 12:44:31 -08:00
parent 618ccebc7f
commit 1059461c6c

View File

@ -16,6 +16,7 @@ INITIAL_COMMIT_MSG="Updated from global requirements"
TOPIC="openstack/requirements"
USERNAME=${USERNAME:-$USER}
BRANCH=$ZUUL_REF
ALL_SUCCESS=0
if [ -z "$BRANCH" ] ; then
echo "No branch set, exiting."
@ -60,11 +61,8 @@ EOF
# make sure the project even has this branch
if git branch -a | grep -q "^ remotes/origin/$BRANCH$" ; then
git checkout $BRANCH
git checkout origin/${BRANCH}
git review -s
if [ -n "$change_id" ] ; then
git review -d $change_id
fi
popd
python update.py $PROJECT_DIR
@ -73,15 +71,22 @@ EOF
if ! git diff --exit-code HEAD ; then
# Commit and review
git_args="-a -F-"
if [ -n "$change_id" ] ; then
git_args="--amend $git_args"
fi
git commit $git_args <<EOF
$COMMIT_MSG
EOF
git review -t $TOPIC $BRANCH
# Do error checking manually to ignore one class of failure.
set +e
OUTPUT=$(git review -t $TOPIC $BRANCH)
RET=$?
[[ "$RET" -eq "0" || "$OUTPUT" =~ "no new changes" ]]
SUCCESS=$?
[[ "$SUCCESS" -eq "0" && "$ALL_SUCCESS" -eq "0" ]]
ALL_SUCCESS=$?
set -e
fi
fi
popd
done
exit $ALL_SUCCESS