Hello,
I'm using a mono-repo with multiple applications in their sub-directory, like
repo
ββ .git
ββ app1
ββ .git
ββ app2
ββ .git
So far, I had installed git_hooks v0.6.5 in the app sub-directories for some pre_commit hook defined for ex. in repo/app1/config/config.exs
like
if Mix.env() != :prod do
config :git_hooks,
auto_install: true,
verbose: true,
hooks: [
pre_commit: [
tasks: [
{:cmd, "mix credo"},
...
but it never worked for me: hooks never got fired automatically.
Then I saw #96.
So I removed repo/app1/.git/hooks/
and I updated to git_hooks v0.7.1
Before that, I had only .samples
in repo/.git/hooks/
.
After the update, a new pre-commit file appeared in repo/.git/hooks
that showed
#!/bin/sh
[ "/Users/jerome/repo/app1/deps/git_hooks" != "" ] && cd /Users/jerome/repo/app1/deps/git_hooks
mix git_hooks.run pre_commit "$@"
[ $? -ne 0 ] && exit 1
exit 0
So, it seems to me that it shouldn't work if I would do it also in app2/
, doesn't it?
Then I tried anyway to commit a file in app1/
with some credo issue I introduced, which produced
repo> cd app1
app1> git commit -m 'test pre-commit hook' lib/app1/worker.ex
Unchecked dependencies for environment dev:
* blankable (Hex package)
the dependency is not available, run "mix deps.get"
* ex_doc (Hex package)
the dependency is not available, run "mix deps.get"
* recase (Hex package)
the dependency is not available, run "mix deps.get"
* dialyxir (Hex package)
the dependency is not available, run "mix deps.get"
* credo (Hex package)
the dependency is not available, run "mix deps.get"
** (Mix) Can't continue due to errors on dependencies
So maybe I did something wrong, but I can't get it to work in my case.
If, just for testing, I change pre-commit
to be
#!/bin/sh
#[ "/Users/jerome/repo/app1/deps/git_hooks" != "" ] && cd /Users/jerome/repo/app1/deps/git_hooks
cd /Users/jerome/repo/app1
...
Then the same test would work
repo> cd app1
app1> git commit -m 'test pre-commit hook' lib/app1/worker.ex
β Running hooks for :pre_commit
...
Γ `pre_commit`: `mix credo` execution failed
Any thought about that? π