Runs the rules in .presubmit.exs (or the built-in defaults) against a
change set and reports each rule as passed, failed, or skipped.
mix presubmit # working tree if dirty, else HEAD
mix presubmit --head # the commit at HEAD
mix presubmit --rev abc123
mix presubmit --staged # from a pre-commit hook
mix presubmit --staged --message-file "$1" # from a commit-msg hook: changes and message together
mix presubmit --worktree # from an editor or agent loop
mix presubmit --range main..HEAD # every commit on a branch
mix presubmit --format json
mix presubmit --listExit status is 0 when every rule passed (or was skipped), 1 when any
failed, and 2 on a usage or configuration error. The first line of output
always names the source examined. With PRESUBMIT_VERDICT=path set, the
verdict (pass or fail) is also written to path once the rules have
run, which is how the hooks tell a failed rule from Mix failing to load the
project before presubmit ran.
Without a .presubmit.exs, the defaults enable Rules.Phoenix and
Rules.Ecto when those libraries are loaded or declared in mix.exs, and
Rules.Changelog when a CHANGELOG.md exists; the output says what was
enabled and why.
A first commit that imports a whole codebase is not a normal commit; the
shape and coverage rules will object. git commit --no-verify is the
intended answer there, once.
The project is not compiled: rules only parse source. Under CI, examining
a dirty working tree prints a warning, since that usually means a build
step modified the checkout; pass --head or --rev to gate the commit.