Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
21 changes: 21 additions & 0 deletions app/lib/mix/tasks/githooks.install.ex
Original file line number Diff line number Diff line change
@@ -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
Comment thread
bougyman marked this conversation as resolved.