Skip to content

Commit 5804e42

Browse files
Merge pull request #199 from kenodegard/disambiguate
Properly disambiguate between branch or file checkout
2 parents b244c38 + e3cb9ba commit 5804e42

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ _switch_to_branch() {
6060
else
6161
# Switch to branch from current Workflow run
6262
# shellcheck disable=SC2086
63-
git checkout $INPUT_BRANCH;
63+
git checkout $INPUT_BRANCH --;
6464
fi
6565
}
6666

tests/git-auto-commit.bats

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,3 +507,29 @@ git_auto_commit() {
507507
run git status
508508
assert_output --partial 'nothing to commit, working tree clean'
509509
}
510+
511+
@test "It does not throw an error if branch is checked out with same name as a file or folder in the repo" {
512+
513+
# Add File called dev and commit/push
514+
echo "Create dev file";
515+
cd "${FAKE_LOCAL_REPOSITORY}";
516+
echo this is a file named dev > dev
517+
git add dev
518+
git commit -m 'add file named dev'
519+
git update-ref refs/remotes/origin/master master
520+
git update-ref refs/remotes/origin/dev master
521+
522+
# ---
523+
524+
INPUT_BRANCH=dev
525+
526+
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{4,5,6}.txt
527+
528+
run git_auto_commit
529+
530+
assert_success
531+
532+
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
533+
assert_line "::set-output name=changes_detected::true"
534+
assert_line "::debug::Push commit to remote branch dev"
535+
}

0 commit comments

Comments
 (0)