Add feature to exit on warning in eol_branch

Change-Id: Ia666a0fb5e1e2fef49bc1639a74a0ab1c63170b1
This commit is contained in:
Joshua Hesketh 2017-07-18 22:32:55 +10:00
parent 1d8e811892
commit 1abd80ed8f
1 changed files with 15 additions and 2 deletions

View File

@ -18,6 +18,7 @@ function print_help {
echo " -h, --help This help message" echo " -h, --help This help message"
echo " -q, --quiet Turn off unimportant messages" echo " -q, --quiet Turn off unimportant messages"
echo " --remote <remote> Set the remote to delete branches from (default: gerrit)" echo " --remote <remote> Set the remote to delete branches from (default: gerrit)"
echo " -w, --warn-exit Exit on any warnings"
echo "" echo ""
} }
@ -34,6 +35,7 @@ EOL_MESSAGE=""
DEBUG= DEBUG=
REMOTE=gerrit REMOTE=gerrit
VERBOSE=true VERBOSE=true
WARN_EXIT=false
while true; do while true; do
case "$1" in case "$1" in
@ -59,6 +61,11 @@ while true; do
shift shift
shift shift
;; ;;
-w|--warn-exit)
WARN_EXIT=true
shift
shift
;;
--) --)
shift shift
break break
@ -125,6 +132,12 @@ function delete_branch {
$DEBUG git push $REMOTE --delete refs/heads/$BRANCH $DEBUG git push $REMOTE --delete refs/heads/$BRANCH
} }
function warning_message {
echo "WARNING: $1"
if [ $WARN_EXIT = true ]; then
exit 1
fi
}
while (( "$#" )); do while (( "$#" )); do
project=$1 project=$1
@ -135,7 +148,7 @@ while (( "$#" )); do
echo "$project not found on filesystem. Will attempt to clone" echo "$project not found on filesystem. Will attempt to clone"
$DEBUG git clone git://git.openstack.org/$project $project $DEBUG git clone git://git.openstack.org/$project $project
else else
echo "$project is not a git repo" warning_message "$project is not a git repo"
echo "skipping..." echo "skipping..."
continue continue
fi fi
@ -146,7 +159,7 @@ while (( "$#" )); do
git remote update --prune git remote update --prune
if ! git rev-parse remotes/$REMOTE/$BRANCH >/dev/null 2>&1; then if ! git rev-parse remotes/$REMOTE/$BRANCH >/dev/null 2>&1; then
echo "$project does not have a branch $BRANCH" warning_message "$project does not have a branch $BRANCH"
echo "skipping..." echo "skipping..."
popd popd
continue continue