Last active
August 29, 2015 14:06
-
-
Save michaelcontento/faa3cf116a958c76f5d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
url_svn() { | |
local svn_branch_url=$(git svn info | grep URL: | cut -d' ' -f2) | |
local svn_branch_url=${svn_branch_url/\/trunk/\/branches} | |
local svn_branch_url=${svn_branch_url/\/trunk\//\/branches} | |
local svn_branch_url=${svn_branch_url/\/branches\/*/\/branches} | |
echo $svn_branch_url | |
} | |
branches_svn() { | |
svn ls $(url_svn) | sed -e 's/\/$//' | |
} | |
branches_git() { | |
git branch --list --remote | sed -e 's/^ //' | grep -v 'trunk' | |
} | |
branches_removed() { | |
local svn_branches=" $(branches_svn) " | |
branches_git | \ | |
while read git_branch; do | |
if ! (echo $svn_branches | grep " $git_branch " >/dev/null); then | |
echo $git_branch | |
fi | |
done | |
} | |
main() { | |
local remove_branches=$(branches_removed) | |
if [ "" = "$remove_branches" ]; then | |
echo "Everything clear." | |
exit 0 | |
fi | |
echo "Branches that will be removed:" | |
echo "==============================" | |
echo $remove_branches | sed -e 's/ /\n/g' | |
echo "" | |
echo -n "Press CTRL-C to abort! Continue in ..."; sleep 1 | |
echo -n " 5"; sleep 1 | |
echo -n " 4"; sleep 1 | |
echo -n " 3"; sleep 1 | |
echo -n " 2"; sleep 1 | |
echo -n " 1"; sleep 1 | |
echo "" | |
echo "" | |
echo "$remove_branches" | \ | |
while read git_branch; do | |
git branch --remote --delete $git_branch | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment