diff --git a/modules/openstack_project/files/slave_scripts/common_translation_update.sh b/modules/openstack_project/files/slave_scripts/common_translation_update.sh index fd0ffb27cc..940fccaa4a 100644 --- a/modules/openstack_project/files/slave_scripts/common_translation_update.sh +++ b/modules/openstack_project/files/slave_scripts/common_translation_update.sh @@ -172,6 +172,30 @@ Change-Id: $change_id EOF set -e fi + # If the open change an already approved, let's not queue a new + # patch but let's merge the other patch first. + # This solves the problem that when the gate pipeline backup + # reaches roughly a day, no matter how quickly you approve the new + # update it will always get sniped out of the gate by another. + # It also helps, when you approve close to the time this job is + # run. + if [ "x${previous}" != "x" ] ; then + # Use the JSON format since it is very compact and easy to grep + change_info=`ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set --format=JSON $change_id` + # Check for: + # 1) Workflow approval (+1) + # 2) no -1/-2 by Jenkins + # 3) no -2 by reviewers + # 4) and no Workflow -1 (WIP) + # + if `echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"1"'` \ + && ! `echo $change_info|grep -q '{"type":"Verified","description":"Verified","value":"-1","grantedOn":[0-9]*,"by":{"name":"Jenkins","username":"jenkins"}}'` \ + && ! `echo $change_info|grep -q '{"type":"Code-Review","description":"Code-Review","value":"-2"'` \ + && ! `echo $change_info|grep -q '{"type":"Workflow","description":"Workflow","value":"-1"'` ; then + echo "Job already approved, exiting" + exit 0 + fi + fi } # Propose patch using COMMIT_MSG