#!/usr/bin/python3 import sys import os lines = sys.stdin.readlines() print("executing merchant post-receive hook") updated = set() for line in lines: try: old, new, name = line.split() except ValueError: print("unexpected format") os.exit(1) updated.add(name) if "refs/heads/test" in updated: ret = os.system("echo merchant | timeout 1s tee /home/test/rebuild >/dev/null") if ret != 0: print("merchant update failed") else: print("updating merchant")