6 def check(args, input=None):
7 return subprocess.check_output(args, text=True, input=input).strip()
10 # config repo and branch
11 REPO = "/srv/git/git-hooks"
17 # list all directories
18 dirs = check(["git", "ls-tree", "--name-only", BRANCH]).splitlines()
22 files = check(["git", "ls-tree", "--name-only", f"{BRANCH}:{d}"]).splitlines()
25 # print the hook and write it to the git repo
26 file = check(["git", "--no-pager", "show", f"{BRANCH}:{d}/{f}"])
28 hookpath = f"/srv/git/{d}/hooks/{f}"
29 with open(hookpath, "w") as fd:
32 check(["chmod", "+x", hookpath])