From 20e5fc23ca14c34125f94c6beb6b5f32183691fa Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 27 Apr 2023 16:56:51 +0200 Subject: [PATCH] Defaulty show detected changes and add full diff (-F) & hide changes (-H) features --- check_git_config | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/check_git_config b/check_git_config index 43e51e5..f5d03b1 100755 --- a/check_git_config +++ b/check_git_config @@ -11,16 +11,20 @@ GIT_ROOT=/srv/common GIT_REMOTE=origin DEBUG=0 CHECK_REMOTE=0 +HIDE_CHANGES=0 +FULL_DIFF=0 function usage() { echo "Usage : $0 -g [directory] [-c|-r remote] [-d] -g [directory] Specify Git root directory (default : $GIT_ROOT) -c Check Git remote state -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" } -while getopts "g:r:cdh-:" OPTION +while getopts "g:r:cdFHh-:" OPTION do case "$OPTION" in c) @@ -36,6 +40,12 @@ do d) DEBUG=1 ;; + H) + HIDE_CHANGES=1 + ;; + F) + FULL_DIFF=1 + ;; h) usage exit 0 @@ -66,6 +76,13 @@ then elif [ -n "$STATUS" ] then 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 elif [ $CHECK_REMOTE -eq 1 ] then