Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Appearance

Conventional commits

cog commit allows you to easily create commits respecting theconventional commits specification. It comes with a set of predefined arguments named after conventional commit types andAngular commit convention: (feat,fix,style,build,refactor,ci,test,perf,chore,revert,docs).

As described in the specification conventional commit messages are structured as follows:

conventional_commit
<type>[optional scope]:<description>[optional body][optional footer(s)]

Allcog commit type subcommands follow the same structure:

sh
cog commit [FLAGS] <type> <message> [scope]

Note that the commit scope comes after the commit description. This allows using positional arguments instead of typing a scope flag every time.

Example:

If you want to create the following commit:feat: add awesome feature:

sh
# With cogcog commit feat"add awesome feature"# With gitgit commit -m"feat: add awesome feature"

Helpful error messages

Usingcog commit should prevent a wide range of errors in your conventional commit message. But if you still made a mistake,cog will display an error explaining what went wrong:

bash
cog commit feat"add ability to parse arrays""sco(pe"Error: A scope value cannot contain inner parenthesisCaused by:     --> 1:9      |    1 | feat(sco(pe): add ability to parse arrays      |         ^---      |      = expected no_parenthesis

Breaking changes

Allcog commit arguments are positional except the optional-B flag used to create breaking changes commits:

bash
cog commit fix -B"add fix a nasty bug" cli

This would create the followingbreaking change commit:fix(cli)!: fix a nasty bug.

cog commit use the! notation to denote breaking changes commit because it can be easily seen in your git log, however if you manually create breaking changes commits withthe footer notation cocogitto tools will still pick them.

Commit Body and footers

If you need to create more complex commit messages with body and footers use the--edit flag.

Example:

bash
cog commit refactor -e -B"drop support for Node 6" runtime

This would open the following commit message template in your$EDITOR of choice:

editor
# Enter the commit message for your changes.# Lines starting with # will be ignored, and empty body/footer are allowed.# Once you are done, save the changes and exit the editor.# Remove all non-comment lines to abort.## WARNING: This will be marked as a breaking change!refactor(runtime): drop support for Node 6# Message body# Message footer# For example, foo: bar

Upon save a commit will be created with the body and footer typed.

TIP

There are two kinds of footer separators in conventional commits:token: message andtoken #message.

GitHub automatically link issues prefixed with a hash.

Example:

    feat(changelog): add full_hash changelog template    Closes #127

Custom commit types

Allowing custom commit types: By defaultcog commit supports standard conventional commits typefeat,fix plus the angular commit types:build,ci,revert,docs,test,style,chore,perf. If you want to use more types you can add them to a file namedcog.toml in your repository root directory:

toml
[commit_types]hotfix = { changelog_title ="Hotfixes" }release = { changelog_title ="Releases" }

The above config would generate acog commit hotfix andcog commit release subcommands following the same structure as the default ones.

Specify custom changelog ordering:

By default commit are ordered by typefeat,fix,perf,revert,docs,test,build,ci,refactor,chore,style in changelogs. The order can be customized by specifying theorder option in the commit object:

toml
[commit_types]hotfix = { changelog_title ="Hotfixes", order =0 }feat = { order =2 }fix = { order =1 }

Overriding existing commit types:

Existing commit type can be overridden just like custom ones:

toml
[commit_types]feat = { changelog_title ="➕ Additional features" }fix = { changelog_title ="🪲 Releases", order =0 }

Omit commits from changelog:

If you want to make changelog more concise you can skip some commit types with theomit_from_changelog option.

toml
[commit_types]chore = { changelog_title ="", omit_from_changelog =true }ci = { changelog_title ="", omit_from_changelog =true }perf = { changelog_title ="", omit_from_changelog =true }

Change the auto-bump behavior for a commit_type: [commit_types] build =

Disabling default commit types:

While active by default, you can disable any of the default commit types by providing an empty configuration:

toml
[commit_types]perf = {}

Deal with merge commits

By default, git will write the following message to merge commit:Merge my 'branch'. These merge commits do not respect the Conventional Commits specification, and we strongly advise avoiding them by setting the following in your.gitconfig:

toml
[merge]ff =only

That said you can simply make Cocogitto ignore merge commits by setting the following in yourcog.toml:

toml
ignore_merge_commits =true

[8]ページ先頭

©2009-2025 Movatter.jp