Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dd031ee58 | |||
| 0f43e8d17a | |||
| 9e07be60d8 | |||
| 71425ec381 | |||
| 1f8ba887fc | |||
| ed88f2a852 | |||
| badb49082f | |||
| bb1d952667 | |||
| 347881f713 | |||
| ee09fe1804 |
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
||||
@@ -2,3 +2,8 @@
|
||||
1. cd .git/hooks
|
||||
2. git clone https://github.com/Marc-Pierre-Barbier/gitHooks
|
||||
3. profit
|
||||
|
||||
|
||||
|
||||
# windows
|
||||
you need to have python3.exe accessible from your path
|
||||
|
||||
+21
-5
@@ -1,8 +1,16 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
banned=["console.log", "<<<< HEAD"]
|
||||
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)
|
||||
@@ -10,9 +18,17 @@ diff = result.stdout.decode("utf-8")
|
||||
files = diff.split("diff --git a/")
|
||||
for file in files:
|
||||
for check in banned:
|
||||
if check in file:
|
||||
print(check + " detected in:")
|
||||
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
|
||||
if check[1] == 1 or check[1] == 0:
|
||||
triggred=1
|
||||
|
||||
if triggred == 1:
|
||||
print(termColor.ERR + "Aborting...")
|
||||
sys.exit(triggred)
|
||||
|
||||
Reference in New Issue
Block a user