aboutsummaryrefslogtreecommitdiff
path: root/bin/git-nuke
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-08-04 21:38:22 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-08-04 21:38:22 +0200
commit126dfe2e2ce38711551adeab0e8f231cfc4c98e4 (patch)
tree74c64b5208445d78b70c32f2b501fbde31c90022 /bin/git-nuke
parent9a6ba2b46cef9797ea1bc5c7ac0d94b8f489d007 (diff)
downloaddotfiles-126dfe2e2ce38711551adeab0e8f231cfc4c98e4.tar.gz
dotfiles-126dfe2e2ce38711551adeab0e8f231cfc4c98e4.zip
Removing unused binaries
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'bin/git-nuke')
-rwxr-xr-xbin/git-nuke17
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/git-nuke b/bin/git-nuke
index f86cb57..037899d 100755
--- a/bin/git-nuke
+++ b/bin/git-nuke
@@ -24,13 +24,22 @@ if [ "$#" -ne 1 ]; then
exit 1
fi
-# The `master` branch should not be removed.
-if [ "$1" = "master" ]; then
- echo "You are not allowed to delete the 'master' branch."
+upstream="origin"
+if [ -n "$1" ]; then
+ upstream="$1"
+fi
+default=$(git rev-parse --abbrev-ref "$upstream"/HEAD | cut -c8-)
+
+# The `default` branch should not be removed.
+if [ "$1" = "$default" ]; then
+ echo "You are not allowed to delete the default branch."
exit 1
fi
-full_name="$(git symbolic-ref HEAD 2>/dev/null)" || (echo "Detached branch, bailing..."; exit 1)
+full_name="$(git symbolic-ref HEAD 2>/dev/null)" || (
+ echo "Detached branch, bailing..."
+ exit 1
+)
name="$(basename "$full_name")"
# If we are nuking the current branch, move to `master` first.