Skip to content

Instantly share code, notes, and snippets.

@lezram
Forked from joshbuchea/semantic-commit-messages.md
Last active November 4, 2023 13:41
Show Gist options
  • Save lezram/7090842f61d5a9a9d4fb8a6c262cc0b3 to your computer and use it in GitHub Desktop.
Save lezram/7090842f61d5a9a9d4fb8a6c262cc0b3 to your computer and use it in GitHub Desktop.
Semantic Commit Messages

Semantic Commit Messages

Semantic Commit Messages enables ...

  • ... automated parsing of commit messages
  • ... easy to read messages
    • ... common understanding of commit messages (within teams/projects/...)
feat(parser): update regex parsing logic
build: bump up jackson from 10.0.0 to 11.0.0

Format

Commit messages consists of a header, a body and a footer.
The header has a special format that includes a type, a scope and a subject:

<type>(<optional scope>): <description>
<BLANK LINE>
<optional body>
<BLANK LINE>
<optional footer>

Keep each line short (about max 100 characters), make it easy to read.

Type

One of the following:

  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm, maven)
  • ci: Changes to CI configuration files and scripts (example scopes: Jenkins, Travis, Circle, BrowserStack, SauceLabs)
  • feat: New feature
  • fix: Bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: Changes that neither fix a bug nor add a feature
  • perf: Change that improve performance
  • test: Adding missing or correcting existing tests

Additional

An additional option is to use tickets (e.g. JIRA) as prefix

  • JIRA-0001: add feature xyz

Revert

Revert a previous commit.

revert: build(maven): bump up jackson from 10.0.0 to 11.0.0

This reverts commit <SHA-REVERTED-COMMIT-HASH>

Scope

The scope could be anything specifying place of the commit change. For example maven, Jenkins, parser, validation, ...

Description

Description of the change:

  • use the imperative, present tense: change not "changed" nor "changes"
  • don't capitalize first letter
  • no dot (.) at the end

Body

Just as in the summary, use the imperative, present tense: fix not "fixed" nor "fixes".

  • why are you making the change
  • motivation for the change
  • comparison of the previous with new behavior (illustrate the impact of the change)

Footer

The footer can contain information about breaking changes.
Also it is the place to reference GitHub issues, Jira tickets, and other PRs that this commit closes or is related to.

BREAKING CHANGE: <breaking change summary>
<BLANK LINE>
<breaking change description + migration instructions>
<BLANK LINE>
<BLANK LINE>
Fixes #<issue number>

Samples

Generic sample:

feat(): add hat wobble
^--^  ^------------^
|     |
|     +-> Summary in present tense. Not capitalized
|
+-------> Type: build, ci, docs, feat, fix, refactor, style, or test.

Version bump:

build: bump up jackson from 10.9.1 to 11.0.0
build(jackson): bump up jackson from 10.9.1 to 11.0.0
build(deps): bump up jackson from 10.9.1 to 11.0.0

Feature

feat(validation): add threshold validation

Sample fix from angular repository

fix(service-worker): correctly handle failed cache-busted request (#39786)

Since 5be4edf, a failing cache-busted
network request (such as requests for fetching uncached assets) will
cause the ServiceWorker to incorrectly enter a degraded
`EXISTING_CLIENTS_ONLY` mode. A failing network request could be caused
by many reasons, including the client or server being offline, and does
not necessarily signify a broken ServiceWorker state.

This commit fixes the logic in `cacheBustedFetchFromNetwork()` to
correctly handle errors in network requests.
For more details on the problem and the implemented fix see #39775.

Fixes #39775

PR Close #39786

Regular expressions (regex)

Header

^(((build|ci|feat|fix|docs|style|refactor|perf|test)(\([^)]{1,}\))?)|(revert)):\s([^A-Z\s].*)$
^(((build|ci|feat|fix|docs|style|refactor|perf|test)(\([^)]{1,}\))?)|(revert)|([^-]+\-[0-9]+)):\s([^A-Z\s].*)$

References

Proudly copied from and inspired by:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment