From 75625df4f37c12d986c51ecc74681d8052c17418 Mon Sep 17 00:00:00 2001
From: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
Date: Tue, 23 Feb 2021 21:14:19 +0100
Subject: [PATCH] Revert "Feature: Create a new branch, if the given branch
 name doesn't exist yet"

---
 entrypoint.sh              | 25 +++----------------------
 tests/git-auto-commit.bats | 22 ----------------------
 2 files changed, 3 insertions(+), 44 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 3ab6ced..0d11b03 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -48,28 +48,9 @@ _switch_to_branch() {
         git fetch --depth=1;
     fi
 
-
-    # If INPUT_BRANCH is empty, just run `git checkout`
-    if [ -z "$INPUT_BRANCH" ]
-    then
-        # shellcheck disable=SC2086
-        git checkout $INPUT_BRANCH;
-    else
-        # 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`
-        # shellcheck disable=SC2086
-        if [ -n "$(git branch --list $INPUT_BRANCH)" ]
-        then
-            # shellcheck disable=SC2086
-            git checkout $INPUT_BRANCH;
-        else
-            # shellcheck disable=SC2086
-            git checkout -b $INPUT_BRANCH;
-        fi
-    fi
-
+    # Switch to branch from current Workflow run
+    # shellcheck disable=SC2086
+    git checkout $INPUT_BRANCH;
 }
 
 _add_files() {
diff --git a/tests/git-auto-commit.bats b/tests/git-auto-commit.bats
index 3e2d006..e3eae71 100644
--- a/tests/git-auto-commit.bats
+++ b/tests/git-auto-commit.bats
@@ -331,25 +331,3 @@ git_auto_commit() {
 
     assert_line "::debug::git-fetch has not been executed"
 }
-
-@test "If INPUT_BRANCH is set and the branch does not exist it creates one" {
-    INPUT_BRANCH="new-branch"
-
-    run git branch
-    refute_line "new-branch"
-
-    touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
-
-    run git_auto_commit
-
-    assert_success
-
-    assert_line "INPUT_BRANCH value: new-branch"
-    assert_line --partial "::debug::Push commit to remote branch new-branch"
-
-    # Assert that branch "new-branch" was updated on remote
-    current_sha="$(git rev-parse --verify --short new-branch)"
-    remote_sha="$(git rev-parse --verify --short origin/new-branch)"
-
-    assert_equal $current_sha $remote_sha
-}