Replace bash scripts with python scripts

This commit is contained in:
Sonny Bakker 2020-07-30 09:10:47 +02:00
parent e382a52cf1
commit b31fe98ad7
12 changed files with 233 additions and 101 deletions

View file

@ -1,13 +1,20 @@
#!/bin/bash
#!/usr/bin/env python
# Use this script in combination with the post-commit.d directory inside .git/hooks/
# to run multiple scripts after commiting
# Check if the directory is the root directory
if [ ! -d ".git/" ]; then
echo "Please commit from within the root directory"
exit 1
fi
import os
import subprocess
import sys
# Run every file inside the post-commit.d directory
for file in .git/hooks/post-commit.d/*
do
. $file
done
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)