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() {
42
42
_check_if_git_is_available
43
43
44
44
_switch_to_repository
45
+
46
+ _check_if_is_git_repository
47
+
48
+ _check_if_repository_is_in_detached_state
49
+
45
50
if " $INPUT_CREATE_GIT_TAG_ONLY " ; then
46
51
_log " debug" " Create git tag only" ;
47
52
_set_github_output " create_git_tag_only" " true"
@@ -100,11 +105,26 @@ _git_is_dirty() {
100
105
gitStatusMessage=" $(( git status - s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED: +${INPUT_FILE_PATTERN_EXPANDED[@]} } >/ dev/ null ) 2 >& 1 )";
101
106
# shellcheck disable=SC2086
102
107
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.";
105
116
exit 1 ;
106
117
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
108
128
}
109
129
110
130
_add_files() {
You can’t perform that action at this time.
0 commit comments