Kiran Manicka
Kiran Manicka

Reputation: 41

Multiple Processes running pre-commit hook

I am currently trying to write a custom pre-commit hook for git. It is python script called secret_detector.py that scans the repository for any accidental sensitive information. I am facing an issue where whenever I try to test it out with a git commit, there are two process that are deployed on this file which creates weird behavior like double printing. The secret_detector.py also has some input output functionality to ask the developer back if the secret in question really is sensitive. The two process running at the same time causes this to behave unexpectedly. I was wondering if there is a way to prevent two processes from being run or if two processes running is indeed expected behavior with pre-commit scripts.

I have added the python script to the .pre-commit-config.yaml with:

id:detect-secrets
name:detect-secrets
entry:python -u hook_scripts/secrets_detector.py
verbose:true
language:python

hook_scripts/secrets_detector.py:

if __name__ == '__main__':
     print(str(os.getpid())+'\n')
     sys.exit(1)

Right now when I git commit, 2 different process ids are printed out.

Upvotes: 0

Views: 82

Answers (0)

Related Questions