From 5e583d32402b9a8f51a688806817370d83590c42 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Thu, 4 Apr 2024 12:25:24 +0200 Subject: [PATCH] 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 --- tools/abandon_old_reviews.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tools/abandon_old_reviews.sh b/tools/abandon_old_reviews.sh index bee03f257b9..301c3842c7a 100755 --- a/tools/abandon_old_reviews.sh +++ b/tools/abandon_old_reviews.sh @@ -30,6 +30,7 @@ DRY_RUN=0 CLEAN_PROJECT="" +UNMAINTAINED=0 function print_help { echo "Script to abandon patches without activity for more than 4 weeks." @@ -40,6 +41,7 @@ function print_help { echo " --project Only check patches from if passed." 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 " --unmaintained Clean all unmaintained branches only. By default unmaintained branches are skipped" echo " --help Print help message" } @@ -57,6 +59,10 @@ while [ $# -gt 0 ]; do shift # past argument shift # past value ;; + --unmaintained) + UNMAINTAINED=1 + shift # past argument + ;; --help) print_help exit 2 @@ -119,7 +125,14 @@ if [ "$PROJECTS" = "()" ]; then exit 1 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 < 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 <