diff --git a/src/_utils/_git_secret_tools.sh b/src/_utils/_git_secret_tools.sh index 356985b8..19db5fcb 100644 --- a/src/_utils/_git_secret_tools.sh +++ b/src/_utils/_git_secret_tools.sh @@ -142,6 +142,12 @@ function _add_ignored_file { } +function _is_inside_git_tree { + git rev-parse --is-inside-work-tree >/dev/null 2>&1 + echo $? +} + + # Logic : function _abort { diff --git a/src/main.sh b/src/main.sh index a4884751..11c22598 100755 --- a/src/main.sh +++ b/src/main.sh @@ -4,7 +4,9 @@ set -e function _check_setup { # Checking git and secret-plugin setup: - if [[ ! -d ".git" ]] || [[ ! -d ".git/hooks" ]]; then + local is_tree + is_tree=$(_is_inside_git_tree) + if [[ $is_tree != "0" ]]; then _abort "repository is broken. try running 'git init' or 'git clone'." fi