diff --git a/publish_images.py b/publish_images.py index 1fc002acb40668defa6fd592b87b8755a83ffa01..f148baefb6d0419aad9695b07acf5826c2371d4f 100755 --- a/publish_images.py +++ b/publish_images.py @@ -4,16 +4,22 @@ import subprocess as sp import sys import time -import git - REGISTRY_URL = 'docker.km3net.de' +def get_changed_dockerfiles(): + """Checks the last Git commit and returns a list of changed Dockefiles""" + diff_cmd = "git diff-tree --no-commit-id --name-only -r HEAD" + child = sp.Popen(diff_cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE) + out, _ = child.communicate() + + changed_files = [l.decode().rstrip() for l in out.split(b'\n')] + changed_dockerfiles = [f for f in changed_files if f.startswith("base/")] + return changed_dockerfiles + + def main(): - changed_dockerfiles = [ - f.a_path for f in git.Repo('.').index.diff("HEAD~1") - if f.a_path.startswith("base/") - ] + changed_dockerfiles = get_changed_dockerfiles() n_files = len(changed_dockerfiles) if n_files == 0: