This repository has been archived on 2025-04-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
git-hooks/post-commit

20 lines
564 B
Python
Executable file

#!/usr/bin/env python
# Use this script in combination with the post-commit.d directory inside .git/hooks/
# to run multiple scripts after commiting
import os
import subprocess
import sys
if not os.path.isdir(".git"):
sys.exit("Please commit from the project root directory")
files = os.scandir(".git/hooks/post-commit.d/")
for executable in files:
try:
subprocess.check_output(
[executable.path], universal_newlines=True, stderr=subprocess.STDOUT
)
except subprocess.CalledProcessError as e:
sys.exit(e.stdout)