32 lines
818 B
Python
Executable File
32 lines
818 B
Python
Executable File
#!/usr/bin/env python3
|
|
import subprocess
|
|
import sys
|
|
|
|
class termColor:
|
|
INFO = '\033[94m'
|
|
GREEN = '\033[92m'
|
|
WARN = '\033[93m'
|
|
ERR = '\033[91m'
|
|
|
|
|
|
# 0 = critical 1 = warning any other value => info
|
|
banned=[["console.log",0], ["<<<< HEAD",0]]
|
|
|
|
triggred=0
|
|
result = subprocess.run(['git', 'diff', '--staged'], stdout=subprocess.PIPE)
|
|
diff = result.stdout.decode("utf-8")
|
|
files = diff.split("diff --git a/")
|
|
for file in files:
|
|
for check in banned:
|
|
if check[0] in file:
|
|
code = "" # info => nocolor
|
|
if check[1] == 0:
|
|
code = termColor.ERR
|
|
if check[1] == 1:
|
|
code = termColor.WARN
|
|
print(code + check[0] + " detected in:")
|
|
print(file.split("\n")[0].split(" b/")[0])
|
|
triggred=1
|
|
|
|
sys.exit(triggred)
|