Merge "Add progress info printouts to list_eol_stale_branches.sh"

This commit is contained in:
Zuul 2023-01-26 12:54:31 +00:00 committed by Gerrit Code Review
commit ec6f4e7a43
1 changed files with 14 additions and 12 deletions

View File

@ -64,52 +64,54 @@ setup_temp_space 'list-eol-stale-branches'
branch=$(series_to_branch "$series")
function no_open_patches {
req="${GERRIT_URL}/changes/?q=status:open+project:${repo}+branch:stable/${em_serie}"
req="${GERRIT_URL}/changes/?q=status:open+project:${repo}+branch:stable/${em_branch}"
patches=$(curl -s ${req} | sed 1d | jq --raw-output '.[] | .change_id')
[ -z "${patches}" ]
no_opens=$?
if [[ "$no_opens" -eq 1 ]]; then
echo "Patches remained open on stale branch (make sure to abandon them):"
echo "https://review.opendev.org/q/status:open+project:${repo}+branch:stable/${em_serie}"
echo "https://review.opendev.org/q/status:open+project:${repo}+branch:stable/${em_branch}"
fi
return $no_opens
}
function eol_tag_matches_head {
head=$(git log --oneline --decorate -1)
[[ "$head" =~ "${em_serie}-eol" ]] && [[ "$head" =~ "origin/stable/${em_serie}" ]]
[[ "$head" =~ "${em_branch}-eol" ]] && [[ "$head" =~ "origin/stable/${em_branch}" ]]
matches=$?
if [[ "$matches" -eq 1 ]] ; then
echo "stable/${em_serie} has patches on top of the ${em_serie}-eol tag"
echo "stable/${em_branch} has patches on top of the ${em_branch}-eol tag"
fi
return $matches
}
function is_eol {
clone_repo ${repo} stable/${em_serie}
cd ${repo} && git checkout -f -q stable/${em_serie} 2>/dev/null
clone_repo ${repo} stable/${em_branch}
cd ${repo} && git checkout -f -q stable/${em_branch} 2>/dev/null
if [[ $? -eq 0 ]]; then
echo "${repo} contains eol stale branch (${em_serie})"
echo
echo "${repo} contains eol stale branch (${em_branch})"
if no_open_patches && eol_tag_matches_head; then
read -p "> Do you want to delete the branch stable/${em_serie} from ${repo} repository? [y/N]: " YN
read -p "> Do you want to delete the branch stable/${em_branch} from ${repo} repository? [y/N]: " YN
if [ "${YN,,}" == "y" ]; then
if [ -z "$gerrit_username" ]; then
read -p "Gerrit username: " gerrit_username
fi
${TOOLSDIR}/delete_stable_branch.py ${gerrit_username} ${repo} ${em_serie}
${TOOLSDIR}/delete_stable_branch.py ${gerrit_username} ${repo} ${em_branch}
fi
fi
cd ..
fi
}
for em_serie in "${em_series[@]}"; do
repos=$(list-deliverables -r --series "${em_serie}" --is-eol)
for em_branch in "${em_series[@]}"; do
repos=$(list-deliverables -r --series "${em_branch}" --is-eol)
# Show the eol stale branches for each repository.
for repo in ${repos}; do
cd ${MYTMPDIR}
echo
is_eol "${repo}" "${em_serie}"
echo " --- $repo ($em_branch) --- "
is_eol "${repo}" "${em_branch}"
done
done