Debian Codegraph @

build-aux/pre-commit.hook

raw
1 #!/bin/sh
2 # Depends on: build-aux/checks.sh
3 # Source: https://gitlab.gnome.org/GNOME/fractal/-/blob/ee6791518094c9c72a0a9630e334f73264f2aff9/hooks/pre-commit.hook
4
5 # Style helpers
6 act="\e[1;32m"
7 err="\e[1;31m"
8 pos="\e[32m"
9 neg="\e[31m"
10 res="\e[0m"
11
12 echo "-- Pre-commit checks --"
13 echo "To ignore these checks next time, run: git commit --no-verify"
14 echo ""
15 if build-aux/checks.sh; then
16 echo ""
17 echo -e "Pre-commit checks result: ${pos}ok${res}"
18 elif [[ $? -eq 2 ]]; then
19 echo ""
20 echo "A missing dependency was found"
21 echo ""
22 echo "y: Skip checks and proceed with commit"
23 echo "N: Abort commit"
24 echo ""
25 while true
26 do
27 echo -n "Skip the pre-commit checks? [y/N]: "; read yn < /dev/tty
28 case $yn in
29 [Yy]* )
30 echo -e " ${act}Skipping${res} checks"
31 exit 0
32 ;;
33 [Nn]* | "" )
34 echo -e " ${err}Aborting${res} commit"
35 exit 1
36 ;;
37 * )
38 echo -e "${neg}Invalid input${res}"
39 ;;
40 esac
41 done
42 else
43 echo ""
44 echo -e "Pre-commit checks result: ${neg}fail${res}"
45 echo ""
46 echo -e " ${err}Aborting${res} commit"
47 exit 1
48 fi