Loads the rule configuration from .presubmit.exs, or builds a
default one from what the examined tree and the VM contain.
The file evaluates to a list of rule-set specs (see Presubmit.RuleSet):
[
Presubmit.Rules.Elixir,
Presubmit.Rules.Phoenix,
{Presubmit.Rules.Ecto, except: [:migrations_reversible]},
{Presubmit.Rules.Message, subject: ~r/^\[[a-z_-]+\] /},
MyApp.CommitRules
]A project-specific rule set can be defined inline in the file with
defmodule, or loaded from another file with Code.require_file/1.
The file is evaluated as code, like mix.exs or .credo.exs; with
--repo that is the other repository's file.
Defaults
Without a file, default/1 enables the sets that apply to the project:
always Hygiene, Mix, OTP, Shape, Elixir's moduledoc and
pure_move, and the message basics (no_fixup, subject_length,
body_line_length);
Phoenix and Ecto when those libraries are loaded in the VM or present
in the examined tree's mix.exs/mix.lock; Changelog's release_logged
when the tree has a CHANGELOG.md. Each set's requires/0 states the
condition, and t/0's :detection records what was decided and why.
The defaults were calibrated against real histories (this workspace's
projects and the Elixir repository): what fails does not fail ordinary
commits. Rules that encode a policy — specs, removals_deprecated,
api_changes_logged, behaviour_changes_tested — run as warnings by
default (warn:); tested is opt-in.
Summary
Functions
Every built-in rule set.
The default configuration for a change set: every built-in default spec whose requirements hold (see the module documentation).
The detection environment for a change set: loaded modules, declared deps, files.
Builds a configuration from rule-set specs.
Loads path (default .presubmit.exs under opts[:repo]), falling
back to default/1 when the default file does not exist. An explicitly
named file that does not exist is an error. commit: feeds detection.
Types
For each candidate default set, whether it was enabled and the reasons.
@type t() :: %Presubmit.Config{ detection: detection(), path: Path.t() | nil, rules: [Presubmit.Rule.t()], sets: [Presubmit.RuleSet.spec()] }
Functions
@spec builtin_sets() :: [module()]
Every built-in rule set.
The default configuration for a change set: every built-in default spec whose requirements hold (see the module documentation).
Pass commit: (or tree:) so dependencies and files can be read from the
examined tree; pass loaded?: to override the VM check (tests).
@spec env(keyword()) :: Presubmit.RuleSet.env()
The detection environment for a change set: loaded modules, declared deps, files.
@spec from_specs([Presubmit.RuleSet.spec()], Path.t() | nil) :: t()
Builds a configuration from rule-set specs.
Loads path (default .presubmit.exs under opts[:repo]), falling
back to default/1 when the default file does not exist. An explicitly
named file that does not exist is an error. commit: feeds detection.