Skip to content

Ensuring conventional commits using Cocogitto

This tutorial explains how to configure cocogitto to verify commits in your repository to conform to conventional commits.

Cocogitto is available from Nixpkgs as cocogitto package. You can add it to the dev shell of your flake.nix:

devShells = {
default = pkgs.mkShell {
packages = [
pkgs.nodePackages.typescript
pkgs.nodePackages.typescript-language-server
pkgs.cocogitto
];
};
};

Then generate cog.toml:

Terminal window
cog init

Cocogitto has a built-in functionality to install git hooks (see the documentation.)

This section describes how to integrate cocogitto into other git-hook frameworks.

TODO: git-hooks.nix currently doesn't support cocogitto out of the box. It supports conform which is an alternative to cocogitto, so it would be possible to cocogitto.

If you are using Lefthook, add the following snippet to lefthook.yml to verify commits in commit-msg hook:

commit-msg:
runner: bash
commands:
cog:
run: |
cog verify --file {1}

Follow the user guide for details.