From 235246de14218233fe007ce7489e5e16c8a91e21 Mon Sep 17 00:00:00 2001 From: Tamas Gal <tgal@km3net.de> Date: Wed, 14 Nov 2018 09:20:57 +0100 Subject: [PATCH] Use shell instead of gitpython --- publish_images.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/publish_images.py b/publish_images.py index 1fc002a..f148bae 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: -- GitLab