Commitlint

This project is an implementation of the Conventional commits specification. This is inspired by the JS library pendant commitlint. The hook installation was inspired by elixir-pre-commit

Installation

If available in Hex, the package can be installed by adding commitlint to your list of dependencies in mix.exs:

def deps do
  [
    {:commitlint, "~> 0.1.0", runtime: false, only: :dev}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/commitlint.

Configuration

The configuration is done in the config/config.exs file. The default configuration is:

config :commitlint,
  allowed_types: [
    "feat",
    "fix",
    "docs",
    "style",
    "refactor",
    "perf",
    "test",
    "build",
    "ci",
    "chore",
    "revert"
  ]

Usage

The package provides a mix task commit_lint. If you want to try it out, you can run:

echo "feat: add commit linting" | mix commit_lint  # Should have exit error 0
echo "unknown: add commit linting" | mix commit_lint  # Should have exit error 1

Upon compilation, the package will install a commit-msg hook in the .git/hooks directory. This will take care of running the commit linting on every commit.

Contributing

If you want to contribute, you are welcome to posting issues and PRs, just make sure to follow the Conventional commits standard.

Local development

First fork the repository, clone your fork, install the dependencies and compile everything:

git clone <your fork>
cd elixir-commitlint
mix deps.get
mix compile

To ensure that your commits are following the conventional commits, you can use, well, commitlint :)

cp priv/commit-msg .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg

Use the following to run the test cases:

mix test

License

See LICENSE for details.