Created fail_if_not_git_repo function and prepended it to all git functions

This commit is contained in:
Nathan Broadbent
2012-09-19 21:34:03 +12:00
parent 197dcfc74f
commit 384f2a0668
3 changed files with 14 additions and 5 deletions

View File

@@ -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
}