Cocogitto

The Conventional Commits toolbox

  • Verified commits: create conventional compliant commits with ease.
  • Automatic Version bump and changelog: automatically bump versions and generate changelogs with your own custom steps and workflows.
  • Release profiles: your branching model requires different steps for releases, pre-release, hotfixes ? We got you covered !
  • Depends only on libgit2: cocogitto has one standalone binary, the only system dependency is libgit2.
  • Conventional git log: search your commit history matching Conventional Commits items such as scope and commit type.
  • GitHub integration: enforce the conventional commits specification with our GitHub action and bot.
  • Monorepo support: Automatic versioning for mono-repositories is supported out of the box.

Usage

Init

Init a repository:

cog init [path]

Commits

Commiting with Conventional Commits. You can add additional commit types in the configuration.

cog commit [FLAGS] <type> <message> [scope]
 
# Commit Example
cog commit refactor -e -B "drop support for Node 6" runtime
Commit OptionDescription
-B, --breaking-changeCreate a BREAKING CHANGE commit
-e, --editOpen commit message in an editor
-s, --signSign this commit
--skip-ciAdd the skip-ci string defined in the cog.toml (or defaults to [skip ci]) to the commit
--skip-ci-override <SKIP_CI_OVERRIDE>Override and add the <SKIP_CI_OVERRIDE> string to the commit
-a, --addAdd files to the commit (similar to git add .)
-u, --updateUpdate but doesn’t add files to the commit (similar to git add -u .)
# See git log with conventional commit info
cog log [options]
OptionDescription
-B, --breaking-changeFilter BREAKING CHANGE commits
-t, --type <type>Filter on commit type
-a, --author <AUTHOR>Filter on commit author
-s, --scope <SCOPE>Filter on commit scope
-e, --no-errorOmit error on the commit log

Compliance

# Check commit history for conventional commit compliance
cog check [-l, --from-latest-tag] [-i, --ignore-merge-commits]
 
# Check a single commit msg
cog verify <msg>
 
# Rewrite the history to be compliant. This lets you edit every invalid msg in $EDITOR
cog edit

Hooks

You can specify git hooks in the configuration and use them:

# Install all git-hooks:
cog install-hook --all
 
# Install a single hook:
cog install-hook commit-msg

Versioning

Get the current version:

cog get-version [-i, --include-prereleases] [--package <PACKAGE>] [-f, --fallback <FALLBACK_VERSION>] [-t, --tag]

Create a new versioned release:

cog bump [OPTIONS] <--version <VERSION>|--auto|--major|--minor|--patch>
 
# Automatic Versioning
cog bump --auto
 
# Dryrun
cog bump --dry-run --auto
 
# Explicitly set a version
cog bump --version <version>
OptionDescription
--version <VERSION>Manually set the target version.
-a, --autoAutomatically suggest the target version.
-M, --majorIncrement the major version.
-m, --minorIncrement the minor version.
-p, --patchIncrement the patch version.
--pre <PRE>Set the pre-release version.
--build <BUILD>Set the build suffix.
-H, --hook-profile <HOOK_PROFILE>Specify the bump profile hooks to run.
--package <PACKAGE>Specify which package to bump for monorepo.
-A, --annotated <ANNOTATED>Annotate tag with given message.
-d, --dry-runDry-run: print the target version; no action taken.
--skip-ciAdd the skip-ci string defined in cog.toml (or defaults to [skip ci]) to the bump commit.
--skip-ci-override <SKIP_CI_OVERRIDE>Override and add the skip-ci string with the provided value to the bump commit.
--skip-untrackedDon’t fail if there are untracked or uncommitted files.
--disable-bump-commitDisable the creation of the bump commit.
--include-packagesAlso bump packages on manual bump. Overrides default behaviour of --patch, --minor, --major, and --version for monorepos. Useful for bumping to version 1.0.0.

NOTE: Configure the bump hooks in cog.toml as well for your project. You can write pre and post bump hooks to automate what needs to happen for a release (eg. setting the new version in some manifest files, etc).

Changelog

Display a changelog for the given commit oid range

Usage: cog changelog [OPTIONS] [RANGE]

OptionDescription
-a, --at <AT>Generate the changelog for a specific git tag.
-t, --template <TEMPLATE>Generate the changelog with the given template. Possible values: remote, full_hash, default, or a path to your template. If not specified, cog will use cog.toml template config or fallback to default.
-r, --remote <REMOTE>URL to use during template generation.
-o, --owner <OWNER>Repository owner to use during template generation.
--repository <REPOSITORY>Name of the repository used during template generation.
-u, --unifiedCombine package and global changes into one changelog.

Configuration

# Whether to only consider commits since the latest SemVer tag.
from_latest_tag = true
# Dont write a CHANGELOG file
disable_changelog = true
 
# Ignore specific non compliant commits
ignore_merge_commits = false
ignore_fixup_commits = true
 
# Disable a commit when version is bumped
disable_bump_commit = false
 
# Only allow bumping the version on matching branches
branch_whitelist = ["main"]
 
# Commit msg extra for skipping CI
skip_ci = "[skip ci]"
# Allows to perform bump even if there are untracked or uncommitted changes.
skip_untracked = false
 
# A prefix for version tags
tag_prefix = "v"
 
# Bump Hooks (Example)
pre_bump_hooks = [
  "cargo build --release",
  "cargo set-version {{version}}",
]
post_bump_hooks = [
  "git push",
  "git push origin {{version_tag}}",
]
 
# Custom commit types
[commit_types]
hotfix = { changelog_title = "Hotfixes" }
release = { changelog_title = "Releases" }
 
[commit_types.myowntype]
# Allow for this commit type to bump the minor version.
# bump_minor = true
# Allow for this commit type to bump the patch version.
# bump_patch = true
# Define the title used in generated changelog for this commit type.
changelog_title = "My Own Type"
# Do not display this commit type in changelogs.
omit_from_changelog = false
# Specify a sort order attribute for this commit type.
order = 10
 
# Git Hook Definition
# script can also be a path to a script file
[git_hooks.pre-commit]
script = """#!/bin/sh
set -e
cargo fmt -v --all --check
cargo clippy
"""

Templates

You can modify the CHANGELOG via a template. The templates are written using tera. For more info see template reference.