From bf97e83d242d54c140c868fbc309d5add16c194a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 16 Dec 2023 23:52:35 -0800 Subject: [PATCH] Add a build script This script does what was previously done by the git hook script. It takes the commit before the push and the one after the push and lists the directories that have been affected in those commits. This script doesn't yet start an actual process for processing the directories, it just prints what it thinks a command line might look like. --- build/freeloadio.run | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 build/freeloadio.run diff --git a/build/freeloadio.run b/build/freeloadio.run new file mode 100755 index 0000000..7f2979e --- /dev/null +++ b/build/freeloadio.run @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +from os import getenv +from os.path import dirname +from re import match +from shlex import quote +from subprocess import run + +commit_before_sha = getenv('CI_COMMIT_BEFORE_SHA') +commit_sha = getenv('CI_COMMIT_SHA') +commit_ref_name = getenv('CI_COMMIT_REF_NAME') +directories = set() + +cmd = 'git clone https://code.ryuslash.org/ryuslash/git-lfs-test.git .' +print(cmd) +run(cmd, shell=True) + +if not match(r"^0+$", commit_before_sha): + cmd = f"git diff --name-only {quote(commit_before_sha)} {quote(commit_sha)}" + print(cmd) + process = run(cmd, shell=True, capture_output=True) + process_output = process.stdout.decode() + print(process_output) + for filename in process_output.strip().split('\n'): + directories.add(dirname(filename)) + +unix_directory_list = str.join(':', directories) +print(f'python tasks.py probe --directories={quote(unix_directory_list)}')