Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Update hooks tools installation

Gabe Kangas42f968c0970d
diff --git a/Makefile b/Makefile
index ccefb8aeef..a65e7a8f38 100644
--- a/Makefile
+++ b/Makefile
@@ -30,11 +30,21 @@ $(OAPI_CODEGEN):
## Install git hooks using lefthook
install-hooks: $(LEFTHOOK)
- $(LEFTHOOK) install
- @echo "Patching hooks to use ./bin/lefthook..."
+ $(LEFTHOOK) install --force
+ @echo "Patching hooks with self-healing bootstrap..."
@for hook in .git/hooks/*; do \
- if [ -f "$$hook" ] && grep -q 'call_lefthook' "$$hook" && ! grep -q 'export LEFTHOOK_BIN' "$$hook"; then \
- sed -i.bak 's|call_lefthook|export LEFTHOOK_BIN="$$(git rev-parse --show-toplevel)/bin/lefthook"; call_lefthook|' "$$hook" && rm -f "$$hook.bak"; \
+ if [ -f "$$hook" ] && grep -q '^call_lefthook run' "$$hook" && ! grep -q 'OWNCAST_LEFTHOOK_BOOTSTRAP' "$$hook"; then \
+ awk '/^call_lefthook run/ && !done { \
+ print "# OWNCAST_LEFTHOOK_BOOTSTRAP - regenerated by make install-hooks"; \
+ print "__owncast_dir=\"$$(git rev-parse --show-toplevel)\""; \
+ print "LEFTHOOK_BIN=\"$$__owncast_dir/bin/lefthook\""; \
+ print "if [ ! -x \"$$LEFTHOOK_BIN\" ]; then"; \
+ print " echo \"bin/lefthook missing; bootstrapping via make install-tools...\" >&2"; \
+ print " (cd \"$$__owncast_dir\" && make install-tools) >&2 || exit 1"; \
+ print "fi"; \
+ print "export LEFTHOOK_BIN"; \
+ done = 1 \
+ } { print }' "$$hook" > "$$hook.new" && mv "$$hook.new" "$$hook" && chmod +x "$$hook"; \
fi \
done
@echo "Hooks installed successfully"