elixir_git_hooks icon indicating copy to clipboard operation
elixir_git_hooks copied to clipboard

Running pre-commit hook only for staged files

Open PaulaSazonov opened this issue 2 months ago • 0 comments

I'm trying to implement a pre-commit hook that would run mix format and mix credo only on staged files, but defining hook e.g. config :git_hooks, hooks: [ pre_commit: [ verbose: true, tasks: [ {:mix_task, :credo} ], ] ] runs mix credo for all source files. Is it possible to define the hook to take only the staged files as arguments for the mix command? Writing a script for this works when I execute it with {:cmd, "bash script.sh"} but I don't get the colored output I can by running the mix task, and {:file, "script.sh"} fails because of :eacces error. Any guidance would be appreciated!

PaulaSazonov avatar Apr 15 '24 13:04 PaulaSazonov