githooks

GIT hook -> Python -> Bash: How to read user input?

GIT hook -> Python -> Bash: How to read user input? Question: I’m doing a GIT hook in Python 3.5. The python script calls a Bash script that that reads input from the user using read command. The bash script by itself works, also when calling directly the python script, but when GIT runs the …

Total answers: 4

Prevent pdb or pytest set_trace from being committed using a pre commit hook

Prevent pdb or pytest set_trace from being committed using a pre commit hook Question: I’d like to create a git pre commit hook that prevents an uncommented pytest.set_trace() or a pdb.set_trace() and other .set_trace(). This is because I debug from the command line often and sometimes forget that I left the debug statement in the …

Total answers: 1

remote: ImportError: No module named gitlab

remote: ImportError: No module named gitlab Question: I wrote gitlab hook with python. And added to post-receive hooks in gitlab server. When i push to remote origin server from my laptop, i get following error. But it works when i run script manually in gitlab server. How can i solve problem? Counting objects: 3, done. …

Total answers: 2

How do I check for valid Git branch names?

How do I check for valid Git branch names? Question: I’m developing a git post-receive hook in Python. Data is supplied on stdin with lines similar to ef4d4037f8568e386629457d4d960915a85da2ae 61a4033ccf9159ae69f951f709d9c987d3c9f580 refs/heads/master The first hash is the old-ref, the second the new-ref and the third column is the reference being updated. I want to split this into …

Total answers: 8

Commit in git only if tests pass

Commit in git only if tests pass Question: I’ve recently started using git, and also begun unit testing (using Python’s unittest module). I’d like to run my tests each time I commit, and only commit if they pass. I’m guessing I need to use pre-commit in /hooks, and I’ve managed to make it run the …

Total answers: 3