Defaulty show detected changes and add full diff (-F) & hide changes (-H) features

This commit is contained in:
Benjamin Renard 2023-04-27 16:56:51 +02:00
parent afdb389214
commit 20e5fc23ca
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -11,16 +11,20 @@ GIT_ROOT=/srv/common
GIT_REMOTE=origin GIT_REMOTE=origin
DEBUG=0 DEBUG=0
CHECK_REMOTE=0 CHECK_REMOTE=0
HIDE_CHANGES=0
FULL_DIFF=0
function usage() { function usage() {
echo "Usage : $0 -g [directory] [-c|-r remote] [-d] echo "Usage : $0 -g [directory] [-c|-r remote] [-d]
-g [directory] Specify Git root directory (default : $GIT_ROOT) -g [directory] Specify Git root directory (default : $GIT_ROOT)
-c Check Git remote state -c Check Git remote state
-r [remote] Specify Git remote to check (default : $GIT_REMOTE) -r [remote] Specify Git remote to check (default : $GIT_REMOTE)
-H Hide detected changes
-F Show full diff in case of changes detected (default: short)
-d Enable debug mode" -d Enable debug mode"
} }
while getopts "g:r:cdh-:" OPTION while getopts "g:r:cdFHh-:" OPTION
do do
case "$OPTION" in case "$OPTION" in
c) c)
@ -36,6 +40,12 @@ do
d) d)
DEBUG=1 DEBUG=1
;; ;;
H)
HIDE_CHANGES=1
;;
F)
FULL_DIFF=1
;;
h) h)
usage usage
exit 0 exit 0
@ -66,6 +76,13 @@ then
elif [ -n "$STATUS" ] elif [ -n "$STATUS" ]
then then
echo "WARNING : Git config repo on $( hostname ) not clean" echo "WARNING : Git config repo on $( hostname ) not clean"
if [ $FULL_DIFF -eq 1 ]
then
git diff
elif [ $HIDE_CHANGES -ne 1 ]
then
echo -e "$STATUS"
fi
exit 1 exit 1
elif [ $CHECK_REMOTE -eq 1 ] elif [ $CHECK_REMOTE -eq 1 ]
then then