From 126dfe2e2ce38711551adeab0e8f231cfc4c98e4 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 4 Aug 2024 21:38:22 +0200 Subject: Removing unused binaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- bin/git-nuke | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'bin/git-nuke') 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. -- cgit v1.2.3