mirror of https://github.com/zulip/zulip.git
tools: Update clean-branches to clean review branches.
This commit is contained in:
parent
443e31e348
commit
a4b76e78ac
|
@ -1,10 +1,20 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# usage: clean-branches
|
||||||
# Deletes any local branches which are ancestors of origin/master,
|
# Deletes any local branches which are ancestors of origin/master,
|
||||||
# and also any branches in origin which are ancestors of
|
# and also any branches in origin which are ancestors of
|
||||||
# origin/master and are named like $USER-*.
|
# origin/master and are named like $USER-*.
|
||||||
|
|
||||||
|
# usage: clean-branches --reviews
|
||||||
|
# Deletes all the above mentioned branches as well as branches
|
||||||
|
# created by the scripts like `fetch-rebase-pull-request`. Be careful
|
||||||
|
# as this would also remove other branches woth names like review-*
|
||||||
|
|
||||||
|
review=0
|
||||||
|
if [ $# -ne 0 ] && [ "$1" == "--reviews" ]; then
|
||||||
|
review=1
|
||||||
|
fi
|
||||||
push_args=()
|
push_args=()
|
||||||
|
|
||||||
function is_merged {
|
function is_merged {
|
||||||
|
@ -18,6 +28,14 @@ function clean_ref {
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
refs/heads/review-*)
|
||||||
|
if [ $review -ne 0 ]; then
|
||||||
|
echo -n "Deleting local branch $(echo "$ref" | sed 's!^refs/heads/!!')"
|
||||||
|
echo " (was $(git rev-parse --short "$ref"))"
|
||||||
|
git update-ref -d "$ref"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
refs/heads/*)
|
refs/heads/*)
|
||||||
if is_merged "$ref"; then
|
if is_merged "$ref"; then
|
||||||
echo -n "Deleting local branch $(echo "$ref" | sed 's!^refs/heads/!!')"
|
echo -n "Deleting local branch $(echo "$ref" | sed 's!^refs/heads/!!')"
|
||||||
|
|
Loading…
Reference in New Issue