From 7f1c755c4e1a148054fe047b1781555b5a094deb Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 16 Dec 2023 23:50:11 -0800 Subject: [PATCH] Reduce scope of the git hook script The git hook script should only extract the necessary information the build script needs to operate. Right now this is only the commit before the push and after the push, and the refname is added for future use. The name of the variables passed to the laminar build are modeled after those found in the GitLab CI documentation, just for some familiarity. The functionality of finding the relevant directories has been moved to the build script. --- build/git-post-receive-hook | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/build/git-post-receive-hook b/build/git-post-receive-hook index 8376535..4005696 100755 --- a/build/git-post-receive-hook +++ b/build/git-post-receive-hook @@ -3,26 +3,21 @@ from shlex import quote from subprocess import run import os -import re import sys -directories = set() - for line in sys.stdin: - precommit, postcommit, refname = line.split(' ') + precommit, postcommit, refname = line.strip().split(' ') if not refname == "refs/heads/main": - print(f"Skipping ref {refname}") + 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}") + os.putenv("LAMINAR_REASON", "Push to git repository") + cmd = "laminarc queue freeloadio " \ + f"CI_COMMIT_BEFORE_SHA={quote(precommit)} " \ + f"CI_COMMIT_SHA={quote(postcommit)} " \ + f"CI_COMMIT_REF_NAME={quote(refname)}" + print(cmd) + process = run(cmd, shell=True, capture_output=True) + buildname, buildrun = process.stdout.decode().strip().split(':') + print(f"Queued build: https://laminar.ryuslash.org/jobs/{buildname}/{buildrun}")