From 760e64b864ad75ebc54b0c7d84cbb326bfcf1c95 Mon Sep 17 00:00:00 2001 From: spacewander Date: Fri, 1 Oct 2021 20:01:47 +0800 Subject: [PATCH] git-delete-squashed-branches: fail fast if can't checkout --- bin/git-delete-squashed-branches | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/git-delete-squashed-branches b/bin/git-delete-squashed-branches index 6707da0..25359fc 100755 --- a/bin/git-delete-squashed-branches +++ b/bin/git-delete-squashed-branches @@ -1,10 +1,11 @@ #!/usr/bin/env bash -targetBranch=$1 +set -euo pipefail -if [[ -z $targetBranch ]]; then +if [[ $# -eq 0 ]]; then targetBranch=$(git rev-parse --abbrev-ref HEAD) else + targetBranch=$1 git checkout $targetBranch fi