Compare commits

..

10 Commits

Author SHA1 Message Date
Marc barbier 5dd031ee58 Update README.md 2021-06-29 11:58:52 +02:00
Marc barbier 0f43e8d17a Merge pull request #1 from Marc-Pierre-Barbier/add-license-1
Create LICENSE
2021-06-29 11:57:23 +02:00
Marc barbier 9e07be60d8 Create LICENSE 2021-06-29 11:57:12 +02:00
Marc BARBIER 71425ec381 only wanr and err can abort 2021-06-29 11:51:23 +02:00
Marc barbier 1f8ba887fc Update README.md 2021-06-29 11:48:13 +02:00
Marc BARBIER ed88f2a852 Merge branch 'main' of https://github.com/Marc-Pierre-Barbier/gitHooks into main 2021-06-29 11:47:13 +02:00
Marc BARBIER badb49082f windows fix 2021-06-29 11:46:49 +02:00
Marc barbier bb1d952667 Update README.md 2021-06-29 11:45:15 +02:00
Marc BARBIER 347881f713 changement numerotation 2021-06-29 11:39:19 +02:00
Marc BARBIER ee09fe1804 python color 2021-06-29 11:38:06 +02:00
3 changed files with 50 additions and 5 deletions
+24
View File
@@ -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>
+5
View File
@@ -2,3 +2,8 @@
1. cd .git/hooks 1. cd .git/hooks
2. git clone https://github.com/Marc-Pierre-Barbier/gitHooks 2. git clone https://github.com/Marc-Pierre-Barbier/gitHooks
3. profit 3. profit
# windows
you need to have python3.exe accessible from your path
+21 -5
View File
@@ -1,8 +1,16 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import subprocess import subprocess
import sys 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 triggred=0
result = subprocess.run(['git', 'diff', '--staged'], stdout=subprocess.PIPE) 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/") files = diff.split("diff --git a/")
for file in files: for file in files:
for check in banned: for check in banned:
if check in file: if check[0] in file:
print(check + " detected in:") 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]) 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) sys.exit(triggred)