releases/tools/abandon_patches_on_unmaintained_branch.sh
Dr. Jens Harbott 54c6dd50da Update tooling to delete unmaintained branches
The tools/list_eol_stale_branches.sh script needs to handle
unmaintained/* branches in addition to stable/* branches, the former
also need to be deleted once the matching *-eol tag has been added to a
repository. In addition it needs to handle the delta between series and
branch names starting with 2023.1/antelope.

Also add a script to abandon open reviews on unmaintained branches, which
is a requirement in order to be able to delete them.

Change-Id: Iba0a50ad0d92013362e2a5eca5a4b1968e6acaf9
2024-12-11 14:40:00 +01:00

64 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# This script helps to abandon open patches when a given branch transitions
# to Unmaintained or End of Life and all patches on stable/<series> branch
# needs to be abandoned in order to be able to delete that branch.
set -e
if [[ $# -lt 2 ]]; then
echo "Usage: $(basename $0) <branch> <repo> [<repo>...]"
echo "repo should be e.g. glance"
echo
echo "Example: $(basename $0) yoga \$(list-deliverables --series yoga --is-eol)"
echo
echo " !!! WARNING: please do not run this script without discussing it"
echo " first with release managers!"
exit 1
fi
series="$1"
shift
repos="$@"
function abandon_change {
gitid=$1
msg=$2
commit_message=$(ssh review.opendev.org "gerrit query $gitid --current-patch-set --format json" | head -n1 | jq .subject)
echo "Abandoning: $change -- $commit_message"
ssh review.opendev.org gerrit review $gitid --abandon --message \"$msg\"
}
for repo in $repos; do
echo "Processing repository: $repo..."
open_changes=$(
ssh review.opendev.org "gerrit query --current-patch-set --format json \
status:open branch:unmaintained/${series} project:openstack/${repo}" | \
jq .currentPatchSet.revision | grep -v null | sed 's/"//g'
)
abandon_message="
unmaintained/$series branch of openstack/$repo transitioned to End of Life
and is about to be deleted.
To be able to do that, all open patches need to be abandoned."
for change in $open_changes; do
abandon_change $change "$abandon_message"
done
done