-
Notifications
You must be signed in to change notification settings - Fork 9
/
pre-receive
executable file
·35 lines (30 loc) · 1.04 KB
/
pre-receive
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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
from sys import stdin, exit
from termcolor import colored
from sh import cowsay
from lib.config import config
from lib.javascript import get_receive_errors as get_javascript_errors
from lib.php import get_receive_errors as get_php_errors
if __name__ == "__main__":
receive_able = True
empty_ref = config.get("receive", "EMPTY_REF")
for line in stdin:
rev_old, rev_new, ref = line.split(" ")
if rev_old == empty_ref or rev_new == empty_ref:
continue
print(colored("CodeSniffer check result:", "magenta"))
javascript_errors = get_javascript_errors(rev_old, rev_new)
php_errors = get_php_errors(rev_old, rev_new)
if not javascript_errors and not php_errors:
print(colored(cowsay("Congratulations!!!"), "green", attrs = ["bold"]))
else:
receive_able = False
if javascript_errors:
print(javascript_errors)
if php_errors:
print(php_errors)
if receive_able:
exit(0)
else:
exit(config.getboolean("receive", "REJECT_RECEIVE"))