Created fail_if_not_git_repo function and prepended it to all git functions
This commit is contained in:
@@ -5,4 +5,12 @@ function find_in_cwd_or_parent() {
|
||||
directory="$directory/.."
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function fail_if_not_git_repo() {
|
||||
if ! find_in_cwd_or_parent ".git" > /dev/null; then
|
||||
echo -e "\e[31mNot a git repository (or any of the parent directories)\e[0m"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user