Skip to content

Commit

Permalink
Fail (and log message) if attempting to execute git commands in a dir…
Browse files Browse the repository at this point in the history
…ectory that is not a git-repo.
  • Loading branch information
Constantin Comendant committed Apr 11, 2024
1 parent b0f4d47 commit d3b9619
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ _git_is_dirty() {
echo "INPUT_FILE_PATTERN: ${INPUT_FILE_PATTERN}";
read -r -a INPUT_FILE_PATTERN_EXPANDED <<< "$INPUT_FILE_PATTERN";

# capture stderr
gitStatusMessage="$((git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}} >/dev/null ) 2>&1)"
# shellcheck disable=SC2086
[ -n "$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})" ]
gitStatus="$(git status -s $INPUT_STATUS_OPTIONS -- ${INPUT_FILE_PATTERN_EXPANDED:+${INPUT_FILE_PATTERN_EXPANDED[@]}})"
if [ $? -ne 0 ]; then
_log "error" "git-status failed with:<$gitStatusMessage>";
exit 1
fi
[ -n "$gitStatus" ]
}
_switch_to_branch() {
Expand Down

0 comments on commit d3b9619

Please sign in to comment.