I am trying to restrict the binary file(dll, pdf, exe) committing in our GitLab instance. My moto is need to abort the commit if the commit have binary files. I have the code for aborting the commit in Python,
#!/usr/bin/env python3
import os
def scanDir(dirName):
for root, dirs, files in os.walk(dirName):
for fileName in files:
if fileName.split('.')[-1] in ["txt","dll","pdf"]:
return 1
return 0
My problem in Gitlab have hooks file in ruby, My code is in python, So It doesn`t works in ruby code. (How to load the python file in ruby hook?)
Also I do not know what is path should I need to give in def scanDir(dirName):
I tried my level best , But I can`t able do this in ruby because I newbie to ruby.
Can anyone help to add the hook to restrict the binary file?