-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·34 lines (31 loc) · 900 Bytes
/
pre-commit
File metadata and controls
executable file
·34 lines (31 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
#
# pre-commit hook - called by "git commit" with no arguments.
# The hook should exit with non-zero status to stop the
# commit.
RED="\e[0;31m"
GREEN="\e[0;32m"
ORANGE="\e[0;33m"
BLUE="\e[0;34m"
RESET='\e[0m'
echo "${BLUE}Trying local gitleaks ...${RESET}"
if command -v ddev >/dev/null 2>&1
then
echo "${BLUE}Found ddev command ...${RESET}"
if ! command -v jq >/dev/null 2>&1
then
echo "${RED}jq command is missing. Install with 'apt install jq' and retry ...${RESET}"
exit 1
else
echo "${BLUE}Found jq command ...${RESET}"
fi
state=$(ddev status -j | jq '.raw.services.web.status')
if [ "$state" = "\"running\"" ]; then
echo "${BLUE}DDEV is running ...${RESET}"
exec ddev gitleaks
else
echo "${ORANGE}DDEV not running (status: $state). Skipping local gitleaks ...${RESET}"
fi
else
echo "${ORANGE}ddev command not found, skipping local gitleaks ...${RESET}"
fi