Skip to content

Commit acbe8b1

Browse files
Merge pull request #393 from stefanzweifel/v7-warn-detached-head
2 parents d2e5cae + d185485 commit acbe8b1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

entrypoint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ _main() {
3333

3434
_check_if_is_git_repository
3535

36-
# _check_if_repository_is_in_detached_state
36+
_check_if_repository_is_in_detached_state
3737

3838
if "$INPUT_CREATE_GIT_TAG_ONLY"; then
3939
_log "debug" "Create git tag only";
@@ -110,8 +110,7 @@ _check_if_is_git_repository() {
110110
_check_if_repository_is_in_detached_state() {
111111
if [ -z "$(git symbolic-ref HEAD)" ]
112112
then
113-
_log "error" "Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly.";
114-
exit 1;
113+
_log "warning" "Repository is in a detached HEAD state. git-auto-commit will likely handle this automatically. To avoid it, check out a branch using the ref option in actions/checkout.";
115114
else
116115
_log "debug" "Repository is on a branch.";
117116
fi

tests/git-auto-commit.bats

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,7 @@ END
10871087
assert_line "::error::Not a git repository. Please make sure to run this action in a git repository. Adjust the `repository` input if necessary."
10881088
}
10891089

1090-
@test "It detects if the repository is in a detached state and exits with an error" {
1091-
skip
1090+
@test "It detects if the repository is in a detached state and logs a warning" {
10921091
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
10931092

10941093
run git_auto_commit
@@ -1103,8 +1102,8 @@ END
11031102

11041103
run git_auto_commit
11051104

1106-
assert_failure;
1107-
assert_line "::error::Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly."
1105+
assert_success;
1106+
assert_line "::warning::Repository is in a detached HEAD state. git-auto-commit will likely handle this automatically. To avoid it, check out a branch using the ref option in actions/checkout."
11081107
}
11091108

11101109
@test "it creates a tag if create_git_tag_only is set to true and a message has been supplied" {

0 commit comments

Comments
 (0)