Presubmit (presubmit v0.2.2)

Copy Markdown View Source

Assertions over the shape and contents of git commits, run as a linter.

mix presubmit loads a change set — a commit, the staged index, or the working tree — parses the Elixir it changed into a structural description, and runs the rules in .presubmit.exs against it. See Mix.Tasks.Presubmit for the command line and Presubmit.RuleSet for writing rules.

Programmatic use:

commit = Presubmit.load(source: :auto)
report = Presubmit.Runner.run(commit, Presubmit.Config.load!().rules)

Summary

Functions

Loads a change set.

The concrete source :auto would pick for opts[:repo] right now.

Types

source()

@type source() :: :auto | :head | :staged | :worktree | {:rev, String.t()}

Functions

load(opts \\ [])

@spec load(keyword()) :: Presubmit.Commit.t()

Loads a change set.

Options

  • :repo — repository path (default: the current directory).
  • :source — :head (default), {:rev, rev}, :staged, :worktree, or :auto, which is :worktree when anything on disk differs from HEAD and :head otherwise.
  • :message — raw message text to attach to a :staged or :worktree change set (from a commit-msg hook, say), cleaned as git would.
  • :base — tree-ish to measure a :staged or :worktree change set against instead of HEAD ("HEAD^" while amending).

resolve_source(opts \\ [])

@spec resolve_source(keyword()) :: :head | :staged | :worktree | {:rev, String.t()}

The concrete source :auto would pick for opts[:repo] right now.