All Projects → platisd → Bad Commit Message Blocker

platisd / Bad Commit Message Blocker

Licence: mit
Inhibits commits with bad messages from getting merged

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Bad Commit Message Blocker

Clean Marvel Kotlin
This repository contains a detailed sample app that implements Clean architecture and MVP in Kotlin using RxJava2, Retrofit
Stars: ✭ 27 (-43.75%)
Mutual labels:  travis-ci, continuous-integration
software-practice-thoughts
📚 🐣 软件实践文集。主题不限,思考讨论有趣有料就好,包含如 系统的模型分析/量化分析、开源漫游者指南、软件可靠性设计实践…… 🥤
Stars: ✭ 122 (+154.17%)
Mutual labels:  best-practices, code-review
firebase-ci
Simplified Firebase interaction for continuous integration
Stars: ✭ 71 (+47.92%)
Mutual labels:  travis-ci, continuous-integration
cpp14-project-template
A simple, cross-platform, and continuously integrated C++14 project template
Stars: ✭ 64 (+33.33%)
Mutual labels:  travis-ci, continuous-integration
Cranium
🤖 A portable, header-only, artificial neural network library written in C99
Stars: ✭ 501 (+943.75%)
Mutual labels:  continuous-integration, travis-ci
dump-env
A utility tool to create .env files
Stars: ✭ 81 (+68.75%)
Mutual labels:  travis-ci, continuous-integration
travis-minikube
Run minikube on Travis CI
Stars: ✭ 89 (+85.42%)
Mutual labels:  travis-ci, continuous-integration
docker-fastpath
Only Build Your Docker Images Once
Stars: ✭ 52 (+8.33%)
Mutual labels:  travis-ci, continuous-integration
Cpp Project
Boiler plate template for C++ projects, with CMake, Doctest, Travis CI, Appveyor, Github Actions and coverage reports.
Stars: ✭ 328 (+583.33%)
Mutual labels:  travis-ci, code-review
qodana-action
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at GitHub with Qodana
Stars: ✭ 112 (+133.33%)
Mutual labels:  continuous-integration, code-review
koshry
Run on CI, Apply Rules on the Build and Get the Result back to the Pull Request.
Stars: ✭ 59 (+22.92%)
Mutual labels:  travis-ci, continuous-integration
Bors Ng
👁 A merge bot for GitHub Pull Requests
Stars: ✭ 878 (+1729.17%)
Mutual labels:  continuous-integration, travis-ci
noise-php
A starter-kit for your PHP project.
Stars: ✭ 52 (+8.33%)
Mutual labels:  travis-ci, continuous-integration
travis
⛔ ARCHIVED ⛔ Set Up 'Travis' for Testing and Deployment
Stars: ✭ 61 (+27.08%)
Mutual labels:  travis-ci, continuous-integration
developer-ci-benefits
Talk docs—includes CI (Continuous Integration) benefits, description, and setup tips 💡💪
Stars: ✭ 29 (-39.58%)
Mutual labels:  travis-ci, continuous-integration
LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (+25%)
Mutual labels:  travis-ci, continuous-integration
plugin.video.sendtokodi
📺 plays various stream sites on kodi using youtube-dl
Stars: ✭ 86 (+79.17%)
Mutual labels:  travis-ci, continuous-integration
nightly-docker-rebuild
Use nightli.es 🌔 to rebuild N docker 🐋 images 📦 on hub.docker.com
Stars: ✭ 13 (-72.92%)
Mutual labels:  travis-ci, continuous-integration
drupal9ci
One-line installers for implementing Continuous Integration in Drupal 9
Stars: ✭ 137 (+185.42%)
Mutual labels:  travis-ci, continuous-integration
Builds Tab
Web extension that adds builds tab to Github
Stars: ✭ 24 (-50%)
Mutual labels:  continuous-integration, travis-ci

Bad Commit Message Blocker Build Status

A simple script, doing some natural language processing, to inhibit git commits with bad messages from getting merged.

screenshot

What?

A Python3 script, easy to integrate with various CI machinery (e.g. see GitHub Actions example) that is meant to keep bad commit messages out of a project. It verifies whether the seven rules of a great Git commit message by Chris Beams, are being followed:

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

Why?

The more a project grows in contributors and size, the more important the quality of its commit messages becomes.

It is ultimately hard to quantify what makes a good commit message. However, we can easily determine automatically whether it adheres to most of the git commit message best practices. Having a script to automatically verify that, aside of other rules that you might already enforce (e.g. checking whether a task or a requirement is referenced) can save a lot of time in the long run as well as even avoid conflicts between the reviewer(s) and the reviewee.

After adopting this script, what you get is a set of best practices, agreed upon by the project and automatically applied. This way, everyone has to follow them or CI will not allow that commit in. Simple as that! 😇

How?

Most of the rules are trivial to implement in code, except two of them, no. 5 and no. 7. Specifically, checking whether the commit subject begins with imperative mood is tricky due to limitations of the Natural Language Processing libraries being utilized. You can read more about the constraints here. Essentially, it boils down to the lack of many imperative sentences existing in the datasets used when training the relevant statistical models. Subsequently, the enforcement of this rule might produce some false positive and false negative errors.

On the other hand, verifying whether the commit body actually explains what and why instead of how is not (?) possible, due to the subjective nature of the problem. All in all, in most cases, this is all the reviewers would have to do themselves manually, to ensure the quality of a commit message.

Get started

You need to have Python3 installed and follow the steps bellow:

  • Install TextBlob
    • pip3 install --user textblob
  • Install NLTK corpora
    • python3 -m textblob.download_corpora
  • Run the script to verify a commit message
    • python3 bad_commit_message_blocker.py --message "Add a really cool feature"
  • To define your own maximum character limits, call the script with the appropriate arguments:
    • --subject-limit (defaults to 50) to set the subject line limit. E.g.:
      • python3 bad_commit_message_blocker.py --subject-limit 80 --message "Add a really cool feature"
    • --body-limit (defaults to 72) to set the body line limit. E.g.:
      • python3 bad_commit_message_blocker.py --body-limit 120 --message "Add a really cool feature"

GitHub Action

Now you can use this script as part of your GitHub Actions CI pipeline.

An example configuration can be seen below:

name: Commit messages

on: [pull_request]

jobs:
  check-commit-message:
    runs-on: ubuntu-20.04
    steps:
      - name: Verify commit messages follow best practices in CI
        uses: platisd/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          # Optionally set the subject character limit (default `50`)
          subject_limit: 60
          # Optionally set the body character limit (default `72`)
          body_limit: 100
          # Optionally set the remote branch name to merge (default `master`)
          remote_branch: dev
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].