Replace git hook with a python script
This commit is contained in:
parent
b02f37cfe4
commit
fff0b171aa
1 changed files with 27 additions and 8 deletions
|
@ -1,9 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env python
|
||||||
|
|
||||||
while read precommit postcommit refname
|
from shlex import quote
|
||||||
do
|
from subprocess import run
|
||||||
echo "precommit: ${precommit}; postcommit: ${postcommit}; refname: ${refname}"
|
import os
|
||||||
if [[ "${precommit}" != "0000000000000000000000000000000000000000" ]]; then
|
import re
|
||||||
git diff --name-status $precommit $postcommit
|
import sys
|
||||||
fi
|
|
||||||
done
|
directories = set()
|
||||||
|
|
||||||
|
for line in sys.stdin:
|
||||||
|
precommit, postcommit, refname = line.split(' ')
|
||||||
|
|
||||||
|
if not refname == "refs/heads/main":
|
||||||
|
print(f"Skipping ref {refname}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"precommit: {precommit}; postcommit: {postcommit}; refname: {refname}")
|
||||||
|
|
||||||
|
if not re.match(r"^0+$", precommit):
|
||||||
|
process = run(f"git diff --name-only {quote(precommit)} {quote(postcommit)}", shell=True, capture_output=True)
|
||||||
|
for filename in process.stdout.strip().split(b'\n'):
|
||||||
|
directories.add(os.path.dirname(filename).decode())
|
||||||
|
|
||||||
|
os.putenv("LAMINAR_REASON", "Push to git repository")
|
||||||
|
process = run(f"laminarc queue freeloadio directories={quote(str.join(';', directories))}", shell=True, capture_output=True)
|
||||||
|
buildname, buildrun = process.stdout.strip().split(b':')
|
||||||
|
print(f"Queued build: https://laminar.ryuslash.org/jobs/{buildname}/{buildrun}")
|
||||||
|
|
Loading…
Reference in a new issue