mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-31 06:57:40 +08:00
Fail if attempting to execute git commands in a directory that is not a git-repo. (#326)
* Fail (and log message) if attempting to execute git commands in a directory that is not a git-repo. * Add Test * Code Formatting --------- Co-authored-by: Constantin Comendant <constantin@uberagent.com> Co-authored-by: Stefan Zweifel <stefan@stefanzweifel.dev>
This commit is contained in:
committed by
GitHub
parent
b0f4d47f59
commit
8621497c8c
@@ -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() {
|
||||
|
Reference in New Issue
Block a user