27

Ensure your pull requests follow the Conventional Commits spec

 4 years ago
source link: https://github.com/zeke/semantic-pull-requests
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Semantic Pull Requests

GitHub status check that ensures your pull requests follow the Conventional Commits spec

Using semantic-release and conventional commit messages ? Install this Probot app on your repos to ensure your pull requests are semantic before you merge them.

How it works

:cop: Note! The default behavior of this bot is not to police all commit messages, but rather to ensure that every PR has just enough semantic information to be able to trigger a release when appropriate. The goal is to gather this semantic information in a way that doesn't make life harder for project contributors, especially newcomers who may not know how to amend their git commit history.

By default, only the PR title OR at least one commit messsage needs to have semantic prefix. If you wish to change this behavior, seesection below.

Scenario Status Status Check Message PR title is semantic :green_heart: ready to be squashed any commit is semantic :green_heart: ready to be merged or rebased nothing is semantic :yellow_heart: add a semantic commit or PR title

Example Scenario

Take this PR for example. None of the commit messages are semantic, nor is the PR title, so the status remains yellow:

67jIJbb.png!web

nmUrAzN.png!web

Edit the PR title by adding a semantic prefix like fix: or feat: or any other conventional commit type . Now use Squash and Merge to squash the branch onto master and write a standardized commit message while doing so:

fEvEjm6.png!web

yEfeyqY.png!web

Installation

:point_right: github.com/apps/semantic-pull-requests

Configuration

By default, no configuration is necessary.

If you wish to override some behaviors, you can add a semantic.yml file to your .github directory with the following optional settings:

# Always validate the PR title, and ignore the commits
titleOnly: true
# Always validate all commits, and ignore the PR title
commitsOnly: true
# Always validate the PR title AND all the commits
titleAndCommits: true
# Require at least one commit to be valid
# this is only relevant when using commitsOnly: true or titleAndCommits: true,
# which validate all commits by default
anyCommit: true
# You can define a list of valid scopes
scopes:
  - scope1
  - scope2
  ...
# By default types specified in commitizen/conventional-commit-types is used.
# See: https://github.com/commitizen/conventional-commit-types/blob/v2.2.0/index.json
# You can override the valid types
types:
  - feat
  - fix
  - docs
  - style
  - refactor
  - perf
  - test
  - build
  - ci
  - chore
  - revert
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
allowMergeCommits: true

License

Apache 2.0


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK