From 10ec54e92d8c6af0707b53212e4a1d57eae2c5d5 Mon Sep 17 00:00:00 2001 From: "Tj (bougyman) Vanderpoel" Date: Sun, 9 Aug 2026 22:26:07 -0400 Subject: [PATCH] feat: add mix githooks.install to activate the repo's git hooks githooks/commit-msg exists and correctly calls ci/validate_conventional_commit.sh, but core.hooksPath was never actually configured on any local clone - the hook never fired, which is how fix!(docs)/docs!(licence) (wrong ! position) got committed without ever being caught before push. Adds `mix githooks.install` (git config core.hooksPath githooks) and mentions it in the Readme's Development section. Closes #50. Co-Authored-By: Claude Sonnet 5 --- Readme.adoc | 9 +++++++++ app/lib/mix/tasks/githooks.install.ex | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 app/lib/mix/tasks/githooks.install.ex diff --git a/Readme.adoc b/Readme.adoc index 4a81cd0..5cd33be 100644 --- a/Readme.adoc +++ b/Readme.adoc @@ -265,6 +265,15 @@ $ lproj list --mine == Development +First, activate the repo's git hooks (enforces conventional-commit subjects +before you even push): + +[source,sh] +---- +$ cd app +$ mise exec -- mix githooks.install +---- + The project uses ExUnit and `mix format`. Run tests with: [source,sh] diff --git a/app/lib/mix/tasks/githooks.install.ex b/app/lib/mix/tasks/githooks.install.ex new file mode 100644 index 0000000..463617f --- /dev/null +++ b/app/lib/mix/tasks/githooks.install.ex @@ -0,0 +1,21 @@ +defmodule Mix.Tasks.Githooks.Install do + @moduledoc "Activates this repo's githooks/ (conventional-commit enforcement on commit-msg)." + @shortdoc "Activates the repo's git hooks" + + use Mix.Task + + @impl Mix.Task + def run(_args) do + with {root, 0} <- System.cmd("git", ["rev-parse", "--show-toplevel"], stderr_to_stdout: true), + root = String.trim(root), + {_output, 0} <- + System.cmd("git", ["config", "core.hooksPath", "githooks"], + cd: root, + stderr_to_stdout: true + ) do + Mix.shell().info("githooks activated (core.hooksPath = githooks)") + else + {output, _status} -> Mix.raise("Failed to activate githooks: #{String.trim(output)}") + end + end +end