treesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorpatrick-scho2025-06-03 14:48:23 +0200
committerpatrick-scho2025-06-03 14:48:23 +0200
commitb6f6ce350d6080e2b2b7a6420447307fc93f56c4 (patch)
treee44b5c5cb354defa32f939705f96512c3d046d73
parent1071cff3ca2626dca967eb0989c0874764c460e2 (diff)
downloadgit-hooks-b6f6ce350d6080e2b2b7a6420447307fc93f56c4.tar.gz
git-hooks-b6f6ce350d6080e2b2b7a6420447307fc93f56c4.zip
add comments to git-hooks/post-receive
-rwxr-xr-xgit-hooks/post-receive4
1 files changed, 4 insertions, 0 deletions
diff --git a/git-hooks/post-receive b/git-hooks/post-receive
index 8e4c837..2af01a8 100755
--- a/git-hooks/post-receive
+++ b/git-hooks/post-receive
@@ -11,14 +11,18 @@ def check(args, input=None):
REPO = "/srv/git/git-hooks"
BRANCH = "main"
+# cd into repo
os.chdir(REPO)
+# list all directories
dirs = check(["git", "ls-tree", "--name-only", BRANCH]).splitlines()
for d in dirs:
+ # list all files
files = check(["git", "ls-tree", "--name-only", f"{BRANCH}:{d}"]).splitlines()
for f in files:
+ # print the hook and write it to the git repo
file = check(["git", "--no-pager", "show", f"{BRANCH}:{d}/{f}"])
with open(f"/srv/git/{d}/hooks/{f}", "w") as fd:
fd.write(file)