scripts: Fix delete-remote-branches script
We were deleting patch branches, oops.
This commit is contained in:
parent
2ea9a911af
commit
aea7fb0e42
|
|
@ -2,6 +2,18 @@
|
||||||
# Delete all remote branches that don't have a local copy.
|
# Delete all remote branches that don't have a local copy.
|
||||||
|
|
||||||
remote="rad"
|
remote="rad"
|
||||||
|
remote_branches="$(git for-each-ref --format='%(refname:short)' refs/remotes/rad)"
|
||||||
|
|
||||||
|
# Check that a branch isn't a remote tracking branch.
|
||||||
|
is_remote_branch() {
|
||||||
|
for remote_branch in $remote_branches; do
|
||||||
|
# Remove the "rad/" prefix
|
||||||
|
if [ "$1" = "${remote_branch#rad/}" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Iterate over all remote branches.
|
# Iterate over all remote branches.
|
||||||
for branch in $(git branch -r --format "%(refname:short)"); do
|
for branch in $(git branch -r --format "%(refname:short)"); do
|
||||||
|
|
@ -14,8 +26,12 @@ for branch in $(git branch -r --format "%(refname:short)"); do
|
||||||
|
|
||||||
# Check if the branch doesn't exist locally.
|
# Check if the branch doesn't exist locally.
|
||||||
if ! git rev-parse --quiet --verify "$branch" >/dev/null; then
|
if ! git rev-parse --quiet --verify "$branch" >/dev/null; then
|
||||||
git push -o "no-sync" $remote --delete "$branch"
|
if ! is_remote_branch "$branch"; then
|
||||||
echo "Deleted '$branch'"
|
git push -o "no-sync" $remote --delete "$branch"
|
||||||
|
echo "Deleted '$branch'"
|
||||||
|
else
|
||||||
|
echo "Skipping remote branch '$branch'"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue