Giter Site home page Giter Site logo

seven-rule-msg's Introduction

seven-rule-msg

Build status Npm version License Commit message style

seven-rule-msg in action

Minimal, opinionated commit message validator.

Rules

All rules are inspired from Chris' post and its predecessors.

  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 (not checked)
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how (not checked)

Features

  • No configuration required
  • Beautiful output
  • Read from $1
  • Read from file
  • Read from STDIN
  • Verbose mode
  • Silent mode

Comparison with other tools

Feature seven-rule-msg commitlint node-commit-msg
Ability to test for seven rules
Designed to test for seven rules
Opinionated
Beautiful output
Easy installation
Zero setup
Does one thing (and does it well)
Checks for imperative tense 1 ⚠️ 2 ⚠️ 3

1 Programmatically checking for imperative tense is non-trivial and error-prone

2 Deprecated

3 Requires separate installation of Java 8

Installation

Assuming you have npm installed,

npm install --global seven-rule-msg-cli

Usage

From CLI

See also: usage.txt.

CLI Argument

seven-rule-msg 'Fix all the stuff'

File

seven-rule-msg [--file|-f] <path-to-file>

STDIN

echo 'Fix all the stuff' | seven-rule-msg

As git hook

.git/hooks/commit-msg:

!/bin/sh

seven-rule-msg -f "$1"

Using the node.js API

import validate from 'seven-rule-msg';

const results = validate('A nice lil commit message');

validate(commitMessage: string)

  • Return value: Result[]
    • Length: 7

The ith element of the returned array corresponds to the i + 1th rule.

interface Result {
    readonly rule: Rule,
    readonly type: ResultType
}
interface Rule {
    readonly message: string,
    readonly test?: (commitMessage: string) => boolean;
}

Rules without test methods are informative only. In other words, they cannot be reliably checked programmatically.

enum ResultType {
    pass = 'pass',
    fail = 'fail',
    info = 'info'
}

Badge

Here's a badge to show the world that you follow the seven rules of commit messages.

[![Commit message style](https://img.shields.io/badge/commit%20messages-seven%20rules-blue.svg)](https://chris.beams.io/posts/git-commit)

License

Licensed under the MIT License.

seven-rule-msg's People

Contributors

shreyasminocha avatar stripedpajamas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

seven-rule-msg's Issues

Support scopes

  • [tests] Add tests for uploading should pass
  • [tests] add tests for uploading should fail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.