From 4b8393320bb0143d3c65d3617f0745d6e36a4c95 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 10 Oct 2020 17:54:11 +0200 Subject: [PATCH 1/2] Fetch Repo before git checkout --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e018310..d5e0540 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,6 +39,9 @@ _git_is_dirty() { _switch_to_branch() { echo "INPUT_BRANCH value: $INPUT_BRANCH"; + # Fetch remote to make sure that repo can be switched to the right branch. + git fetch; + # Switch to branch from current Workflow run git checkout $INPUT_BRANCH; } From ebf8a401eeacd815f037a1c4aff56b0ecd17a5d5 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 10 Oct 2020 18:06:55 +0200 Subject: [PATCH 2/2] Fix Tests --- tests/commit.bats | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/commit.bats b/tests/commit.bats index 6994b2d..e75e0f0 100644 --- a/tests/commit.bats +++ b/tests/commit.bats @@ -98,6 +98,7 @@ main() { INPUT_SKIP_DIRTY_CHECK=true shellmock_expect git --type exact --match "status -s ." + shellmock_expect git --type exact --match "fetch" shellmock_expect git --type exact --match "checkout master" shellmock_expect git --type exact --match "add ." shellmock_expect git --type partial --match '-c' @@ -109,10 +110,11 @@ main() { shellmock_verify [ "${capture[0]}" = "git-stub status -s -- ." ] - [ "${capture[1]}" = "git-stub checkout master" ] - [ "${capture[2]}" = "git-stub add ." ] - [ "${capture[3]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite " ] - [ "${capture[4]}" = "git-stub push --set-upstream origin HEAD:master --tags" ] + [ "${capture[1]}" = "git-stub fetch" ] + [ "${capture[2]}" = "git-stub checkout master" ] + [ "${capture[3]}" = "git-stub add ." ] + [ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite " ] + [ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ] # Failed Exit Code [ "$status" -ne 0 ]