File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ _main() {
4242 _check_if_git_is_available
4343
4444 _switch_to_repository
45+
46+ _check_if_is_git_repository
47+
48+ _check_if_repository_is_in_detached_state
49+
4550 if " $INPUT_CREATE_GIT_TAG_ONLY " ; then
4651 _log " debug" " Create git tag only" ;
4752 _set_github_output " create_git_tag_only" " true"
@@ -100,11 +105,26 @@ _git_is_dirty() {
100105 gitStatusMessage=" $(( git status - s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED: +${INPUT_FILE_PATTERN_EXPANDED[@]} } >/ dev/ null ) 2 >& 1 )";
101106 # shellcheck disable=SC2086
102107 gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED: +${INPUT_FILE_PATTERN_EXPANDED[@]} } )";
103- if [ $? -ne 0 ]; then
104- _log "error" "git-status failed with:<$gitStatusMessage >";
108+ [ -n "$gitStatus " ]
109+ }
110+
111+ _check_if_is_git_repository() {
112+ if [ -d ".git" ]; then
113+ _log "debug" "Repository found.";
114+ else
115+ _log "error" "Not a git repository. Please make sure to run this action in a git repository. Adjust the `repository` input if necessary.";
105116 exit 1 ;
106117 fi
107- [ -n "$gitStatus " ]
118+ }
119+
120+ _check_if_repository_is_in_detached_state() {
121+ if [ -z "$(git symbolic-ref HEAD)" ]
122+ then
123+ _log "error" "Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly.";
124+ exit 1 ;
125+ else
126+ _log "debug" "Repository is on a branch.";
127+ fi
108128}
109129
110130_add_files() {
You can’t perform that action at this time.
0 commit comments