From 94941cff883114143a7c3e07a8c1c8466ce26b60 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sun, 7 Feb 2021 16:09:59 +0100 Subject: [PATCH] Cleanup Code --- entrypoint.sh | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5986d5b..bf0f078 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -49,37 +49,24 @@ _switch_to_branch() { fi - - # If INPUT_BRANCH is empty, just run `git checkout` if [ -z "$INPUT_BRANCH" ] then - - # Switch to branch from current Workflow run # shellcheck disable=SC2086 git checkout $INPUT_BRANCH; - else - - # If INPUT_BRANCH is given, check if a branch already exists - # If not create one - - + # If the branch which we should checkout already exists, just + # run `git checkout $INPUT_BRANCH` + # Otherwhise create a new branch by adding the `-b` option to + # `git-checkout` if [ -n "$(git branch --list $INPUT_BRANCH)" ] then - - # Switch to branch from current Workflow run # shellcheck disable=SC2086 git checkout $INPUT_BRANCH; - else - - # Switch to branch from current Workflow run # shellcheck disable=SC2086 git checkout -b $INPUT_BRANCH; - fi - fi }