3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: AGPL-3.0
7 # Provide generic exit strategy for any error in execution
11 if [ "${rc}" -ne 0 ]; then
12 echo "Error occurred (${rc}) while running ${0} at line ${1}: ${BASH_COMMAND}"
18 trap '_exit_handler $LINENO' EXIT ERR
20 # List here branches that you don't want to ever delete, separated with "|"
21 # (as they will be passed as a parameter to egrep)
22 # IE: "keep_this_branch|also_this_other|and_this_one"
23 branches_to_keep="master|integration|dev|staging"
25 git remote update --prune
28 git branch --remote --merged | \
29 egrep -v "/(${branches_to_keep})\$" | \
30 sed 's/origin\///' | \
31 xargs --no-run-if-empty -n 1 git push --delete origin