Skip abandoning of the old patches in unmaintained branches

By default abandon_old_reviews.sh script will now ignore
patches from any unmaintained branches.
Cleanup of those patches can be done by passing "--unmaintained"
parameter to the script

Change-Id: If7626543f9095196ef1515039f153b16282c27a4
This commit is contained in:
Slawek Kaplonski 2024-04-04 12:25:24 +02:00
parent 2db8620523
commit 5e583d3240

View File

@ -30,6 +30,7 @@
DRY_RUN=0 DRY_RUN=0
CLEAN_PROJECT="" CLEAN_PROJECT=""
UNMAINTAINED=0
function print_help { function print_help {
echo "Script to abandon patches without activity for more than 4 weeks." echo "Script to abandon patches without activity for more than 4 weeks."
@ -40,6 +41,7 @@ function print_help {
echo " --project <project_name> Only check patches from <project_name> if passed." echo " --project <project_name> Only check patches from <project_name> if passed."
echo " It must be one of the projects which are a part of the Neutron stadium." echo " It must be one of the projects which are a part of the Neutron stadium."
echo " If project is not provided, all projects from the Neutron stadium will be checked" echo " If project is not provided, all projects from the Neutron stadium will be checked"
echo " --unmaintained Clean all unmaintained branches only. By default unmaintained branches are skipped"
echo " --help Print help message" echo " --help Print help message"
} }
@ -57,6 +59,10 @@ while [ $# -gt 0 ]; do
shift # past argument shift # past argument
shift # past value shift # past value
;; ;;
--unmaintained)
UNMAINTAINED=1
shift # past argument
;;
--help) --help)
print_help print_help
exit 2 exit 2
@ -119,7 +125,14 @@ if [ "$PROJECTS" = "()" ]; then
exit 1 exit 1
fi fi
blocked_reviews=$(ssh review.opendev.org "gerrit query --current-patch-set --format json $PROJECTS status:open age:4w label:Code-Review<=-2" | jq .currentPatchSet.revision | grep -v null | sed 's/"//g') gerrit_query="status:open age:4w label:Code-Review<=-2 "
if [ $UNMAINTAINED -eq 1 ]; then
gerrit_query="${gerrit_query} branch:^unmaintained/.*"
else
gerrit_query="${gerrit_query} NOT branch:^unmaintained/.*"
fi
blocked_reviews=$(ssh review.opendev.org "gerrit query --current-patch-set --format json $PROJECTS $gerrit_query" | jq .currentPatchSet.revision | grep -v null | sed 's/"//g')
blocked_msg=$(cat <<EOF blocked_msg=$(cat <<EOF
@ -144,7 +157,13 @@ done
# then purge all the reviews that are > 4w with no changes and Zuul has -1ed # then purge all the reviews that are > 4w with no changes and Zuul has -1ed
failing_reviews=$(ssh review.opendev.org "gerrit query --current-patch-set --format json $PROJECTS status:open age:4w NOT label:Verified>=1,Zuul" | jq .currentPatchSet.revision | grep -v null | sed 's/"//g') gerrit_query="status:open age:4w NOT label:Verified>=1,Zuul "
if [ $UNMAINTAINED -eq 1 ]; then
gerrit_query="${gerrit_query} branch:^unmaintained/.*"
else
gerrit_query="${gerrit_query} NOT branch:^unmaintained/.*"
fi
failing_reviews=$(ssh review.opendev.org "gerrit query --current-patch-set --format json $PROJECTS $gerrit_query" | jq .currentPatchSet.revision | grep -v null | sed 's/"//g')
failing_msg=$(cat <<EOF failing_msg=$(cat <<EOF