View Source mix git.test (ex_git_test v0.1.0)
Runs mix test
on the latest git commit, plus any staged changes.
Performs the following steps:
Creates a temporary directory (in the standard system location).
Runs
git diff --cached
(in the local tree) to extract staged changes.Clones the local tree into the temporary directory.
Applies the changes extracted in step 2.
Symlinks dependencies from the local
deps
to the cloneddeps
.- This avoids needing to recompile dependencies, which aren't part of the check-in anyway.
Runs
mix test
, capturing the output (both stdout and stderr).- If it passes, great!
- If it fails, dumps the captured output and exits with a non-zero status.
Cleans up the temporary directory on exit.
This is intended to be used as part of a pre-commit hook, to help protect against forgetting to add new files, doing partial commits where some committed changes depend on changes not staged for commit, etc.
Use mix git.test.install
to install the default pre-commit hook.