Fix abandoning reviews in eol_branch

The loop that was meant to abandon all open reviews for an EOL branch was
only getting the 1st one due to the way the ssh output was being read in.

Make this neater by creating an array of revisions from the query to
abandon before looping over them.

Additionally tighten the regex matching the change revision. The gerrit
query returns a lot of information, including the commit message, meaning
that any references to 'revision' in a commit message could be erroneously
matched.

Change-Id: I1dd3a94bec45aaeae9c37af1fd7b18905f0401ef
This commit is contained in:
Joshua Hesketh 2017-09-28 16:52:20 +10:00
parent f58cb68fe1
commit 9a7f57202d
1 changed files with 3 additions and 3 deletions

View File

@ -92,9 +92,9 @@ function abandon_reviews {
fi
gerrit_query="--current-patch-set status:open project:$project branch:$BRANCH"
ssh -p 29418 review.openstack.org gerrit query $gerrit_query |
grep revision | while read -r line; do
rev=`echo $line | cut -b 11-`
revisions=($(ssh -p 29418 review.openstack.org gerrit query $gerrit_query |
grep '^ revision: [a-f0-9]\{40\}$' | cut -b 15-))
for rev in "${revisions[@]}"; do
if [ $VERBOSE = true ]; then
echo "Found commit $rev to abandon"
fi