added function to validate a git repo directory

This commit is contained in:
pyr0ball 2023-05-27 22:21:36 -07:00
parent 9293f97c7d
commit b4b57291bd

View file

@ -253,6 +253,7 @@ box-light(){
box-singlechar(){ box-singlechar(){
set_borders "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "-" set_borders "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "$borderchar" "-"
} }
set-boxtype(){ set-boxtype(){
case $boxtype in case $boxtype in
norm) box-norm ;; norm) box-norm ;;
@ -602,6 +603,22 @@ run-from-url(){
return $ec return $ec
} }
check-git-repository(){
repodir=${1:-$rundir}
if [ -z $repodir ] ; then
warn "check-git-repository() Incorrect usage. Usage: check-git-repository </path/to/dir>"
return 2
fi
if git -C "$repodir" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Directory '$repodir' is a valid Git repository."
return 0
# Your script logic here
else
echo "Directory '$repodir' is not a valid Git repository"
return 1
fi
}
# fancy script exits # fancy script exits
ctrl_c(){ ctrl_c(){