[fractal/fractal-next] pre-commit: Prettify output



commit 627553d415d41f99acc9b01afa438d9595f16f5a
Author: Kévin Commaille <zecakeh tedomum fr>
Date:   Fri Jan 14 23:21:32 2022 +0100

    pre-commit: Prettify output

 hooks/pre-commit.hook | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/hooks/pre-commit.hook b/hooks/pre-commit.hook
index 66f888ac..3bc427dd 100755
--- a/hooks/pre-commit.hook
+++ b/hooks/pre-commit.hook
@@ -1,13 +1,21 @@
 #!/bin/sh
 # Depends on: scripts/checks.sh
 
+# Style helpers
+act="\e[1;32m"
+err="\e[1;31m"
+pos="\e[32m"
+neg="\e[31m"
+res="\e[0m"
+
 echo "-- Pre-commit checks --"
 echo "To ignore these checks next time, run: git commit --no-verify"
 echo ""
 if scripts/checks.sh; then
     echo ""
-    echo "Pre-commit checks result: ok"
+    echo -e "Pre-commit checks result: ${pos}ok${res}"
 elif [[ $? -eq 2 ]]; then
+    echo ""
     echo "A missing dependency was found"
     echo ""
     echo "y: Skip checks and proceed with commit"
@@ -18,20 +26,22 @@ elif [[ $? -eq 2 ]]; then
         echo -n "Skip the pre-commit checks? [y/N]: "; read yn < /dev/tty
         case $yn in
             [Yy]* )
-                echo "Skipping checks…"
+                echo -e "  ${act}Skipping${res} checks"
                 exit 0
                 ;;
             [Nn]* | "" )
-                echo "Aborting commit"
+                echo -e "  ${err}Aborting${res} commit"
                 exit  1
                 ;;
             * ) 
-                echo "Invalid input"
+                echo -e "${neg}Invalid input${res}"
                 ;;
         esac
     done
 else
-    echo "Pre-commit checks result: fail"
-    echo "Aborting commit"
+    echo ""
+    echo -e "Pre-commit checks result: ${neg}fail${res}"
+    echo ""
+    echo -e "  ${err}Aborting${res} commit"
     exit 1
 fi
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]