From a642e912d64a6f17a0204f875217b9006edc9cf8 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Tue, 16 Apr 2019 23:06:16 -0300 Subject: [PATCH] Fix some errors --- ganarchy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ganarchy.py b/ganarchy.py index 5286899..a25d9dc 100755 --- a/ganarchy.py +++ b/ganarchy.py @@ -167,7 +167,7 @@ def cron_target(): def handle_target(url, project_commit): branchname = hashlib.sha256(url.encode("utf-8")).hexdigest() try: - pre_hash = subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%H", "--"], stderr=subprocess.DEVNULL) + pre_hash = subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%H", "--"], stderr=subprocess.DEVNULL).decode("utf-8").strip() except subprocess.CalledProcessError: pre_hash = None try: @@ -176,16 +176,16 @@ def cron_target(): # This may error for various reasons, but some are important: dead links, etc click.echo(e.output, err=True) return None - post_hash = subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%H", "--"], stderr=subprocess.DEVNULL) + post_hash = subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%H", "--"], stderr=subprocess.DEVNULL).decode("utf-8").strip() if not pre_hash: pre_hash = post_hash try: - count = subprocess.check_output(["git", "-C", cache_home, "rev-list", "--count", pre_hash + ".." + post_hash]) + count = int(subprocess.check_output(["git", "-C", cache_home, "rev-list", "--count", pre_hash + ".." + post_hash, "--"]).decode("utf-8").strip()) except subprocess.CalledProcessError: count = 0 # force-pushed try: subprocess.check_call(["git", "-C", cache_home, "merge-base", "--is-ancestor", project_commit, branchname], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - return count, post_hash, subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%B", "--"], stderr=subprocess.DEVNULL) + return count, post_hash, subprocess.check_output(["git", "-C", cache_home, "show", branchname, "-s", "--format=%B", "--"], stderr=subprocess.DEVNULL).decode("utf-8", "replace") except subprocess.CalledProcessError: return None os.makedirs(cache_home, exist_ok=True)