-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpre-push.sh
54 lines (43 loc) · 1.08 KB
/
pre-push.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
end="\033[0m"
function blue { echo -e >&2 "\033[1;34m$@${end}"; }
function lightblue { echo -e >&2 "\033[0;36m$@${end}"; }
function green { echo -e >&2 "\033[1;32m$@${end}"; }
function red { echo -e >&2 "\033[1;31m$@${end}"; }
function onExit {
echo "> Please fix the errors above and try again."
echo "> If you absolutely must, you can ignore these checks by pushing again with the --no-verify flag."
}
trap onExit EXIT
blue "> Running pre-push hooks..."
echo
lightblue "> Formatting code..."
composer lint -- --dry-run
if [[ "$?" -ne 0 ]]; then
echo
red "> Found files that still need linting."
echo "> Run \`composer lint\` to fix these formatting issues then try again."
echo
exit 1
fi
echo
lightblue "> Checking for potential errors..."
composer psalm
if [[ "$?" -ne 0 ]]; then
echo
red "> Found files with code issues."
echo
exit 1
fi
echo
lightblue "> Testing..."
composer test
if [[ "$?" -ne 0 ]]; then
echo
red "> Not all the tests are passing."
echo
exit 1
fi
echo
green "> Code looks good! Pushing..."
echo