Skip to content
Give consistency to your project's git logs.
Branch: master
Clone or download
Latest commit 302976a Jun 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode chore: add vscode setting Mar 8, 2018
lib refactor: make to get version from package.json May 13, 2019
test tada: update to 0.9.9 Jun 9, 2019
.eslintrc chore: set eslint Sep 26, 2018
.git_consistent test(main): add test Nov 11, 2018
.gitcommit_template chore: add issueKeyword to .gitcommit_template Sep 7, 2018
.gitignore docs: write 'README.md' for npm Nov 12, 2018
.node-version up: upgrade node to v12.4.0 Jun 9, 2019
.travis.yml up: upgrade node to v12.0.0 Apr 26, 2019
CHANGELOG.adoc tada: update to 0.9.9 Jun 9, 2019
LICENSE
README.adoc docs: write README.adoc Nov 13, 2018
deploy.sh
package.json
sample_type_list.adoc docs: fix sample_type_list emoji Mar 10, 2018
yarn.lock up: upgrade devDependencies Jun 9, 2019

README.adoc

git-consistent Build Status npm git-consistent friendly

git consistent01

Give consistency to your project’s git logs.

2. Install

$ npm install -g git-consistent
# or
$ yarn global add git-consistent

2.1. Optional settings

# set alias
$ git config --global alias.con "consistent -i"

# setting editor (for text type input) if you use editor other than vim.
$ export EDITOR='code -w'
# or
$ export EDITOR='atom -w'
# or
$ export EDITOR='subl -w'
# or etc.

3. Usage

3.1. Init

$ git consistent init
Use Type? (Y/n): Y
Use Emoji? (y/N): N
Does the subject start with lower case? (Y/n): Y
Does the subject put dot (.) at end? (y/N): Y

Generated '.gitcommit_template' and '.git_consistent'.
You can edit them freely.
Enjoy!

3.2. Output usage

$ git-consistent --help

  Usage: git-consistent [options]


  Options:

    --type <type>            commit type
    -m, --subject <subject>  The subject contains succinct description of the change
    --body [body]            The body contains details of the change (default: )
    ...
    -V, --version            output the version number
    -h, --help               output usage information

3.3. Inline mode

$ git consistent --type="feat" --subject="implement new feature" --body="This is amazing feature."

3.4. Interactive mode

$ git consistent -i
Select type: feat
Enter subject: implement new feature
Enter body multiline:
This is amazing feature.

You can use both mode interactive and inline at the same time. In that case, you input value that are not given as option only.

$ git consistent -i --subject="implement new feature"
Select type: feat
Enter body multiline:
This is amazing feature.

--subject have alias of -m. You can commit like you normally do!

$ git config --global alias.con "consistent -i"
$ git con -m "write README"
? Select type: docs
git commit -m "docs: write README"

3.5. Advance

3.5.1. Decorate

scope:
  type: text
  required: false
  description: 'The scope could be specifying place of the commit change.'
  prefix: '('
  suffix: ')'

3.5.2. format check

subject:
  type: string
  required: true
  description: 'The subject contains succinct description of the change'
  rules:
    firstLatter: lower
    dotAtEnd: false
    ascii: false
$ git consistent --subject="Write documents."
subject must be first latter is lowercase.
subject should put dot (.) at the end.

$ git consistent --subject="ドキュメントを書いた"
subject must be first latter is lowercase.
subject should only alphabet.

3.5.3. variables

<githubIssueNum> <subject>

<githubIssueUrl>
<body>
githubIssueNum:
  type: string
  required: false
  description: 'github issue number'
  prefix: 'fix #'
subject:
  type: string
  required: true
  description: 'The subject contains succinct description of the change'
githubIssueUrl:
  type: variable
  origin: githubIssueNum
  description: 'github issue url'
  prefix: 'https://github.com/isuke/git-consistent/issues/'
body:
  type: text
  default: ''
  required: false
  description: 'The body contains details of the change'
$ git consistent -i --subject="test" --body="This is test."
Enter githubIssueNum: 12

$ git log -n 1
commit a9d6457f3674c8620fbe72c769cee09ba5459f02
Author: isuke <isuke770@gmail.com>
Date:   Sat Feb 10 17:40:33 2018 +0900

    fix #12 test

    https://github.com/isuke/git-consistent/issues/12
    This is test.

3.5.4. branch

<subject>

<issueLink><body>
...
issueLink:
  type: branch
  required: false
  description: 'Github issue link'
  regExp: 'issue([0-9]+)'
  prefix: 'https://github.com/you/repository/issues/'
  suffix: "\n"
...
$ git branch
* issue123_hoge
  master

$ git consistent -i --subject="test" --body="This is test."

$ git log -n 1
commit a9d6457f3674c8620fbe72c769cee09ba5459f02
Author: isuke <isuke770@gmail.com>
Date:   Sat Feb 10 17:40:33 2018 +0900

    test

    https://github.com/you/repository/issues/123
    This is test.

3.5.5. emoji

emoji:
  type: enum
  required: true
  description: 'commit type'
  values:
    -
      name: ':heavy_plus_sign:'
      description: 'when implementing function'
    -
      name: ':sunny:'
      description: 'when fixing a bug'
    -
      name: ':art:'
      description: 'when refactoring'

git consistent02 emoji

3.5.6. git-duet

Run git-duet mode when with -d option.

$ git consistent -d --type="feat" --subject="duet test" --body=""

$ git log -n 1
Author: isuke <isuke770@gmail.com>
Date:   Sat Feb 10 15:13:40 2018 +0900

    feat: duet test

    Signed-off-by: foo <foo@example.con>

4. Type list sample

5. .git_consistent format

<term>:
  <option key>: <option value>
  <option key>: <option value>
  <option key>: <option value>
<term>:
  <option key>: <option value>
  <option key>: <option value>
  <option key>: <option value>
<term>:
  <option key>: <option value>
  <option key>: <option value>
  <option key>: <option value>
key description value

term

.gitcommit_template’s term

string

option key

term’s options

type, required, description, values, prefix, suffix, rules

type

term’s input type

enum, string, text, variable, branch

required

required?

boolean

description

term’s description

string

values

enum’s values

Array

prefix

a decoration to be attached before the input value

string

suffix

a decoration to be attached after the input value

string

regExp

(type: branch only) regular expression for extracting values from branch names

string

regExpMatchNum

(type: branch only) number of values to retrieve from the match specified by regExp

string

regExpFlag

(type: branch only) `regExp’s falg

i

rules

input value format rules

Object

rule key

rule’s type

firstLatter, dotAtEnd, nonAscii, numberOnly

firstLatter

upper case or lower case about input value’s first latter

upper, lower

dotAtEnd

need dot (.) input value’s last

boolean

nonAscii

Use not ascii symbols

boolean

numberOnly

number only?

boolean

maxLength

max length of string

integer

minLength

min length of string

integer

6. Command options

Option Description

-d, --duet

run git-duet mode

-D, --dry-run

run dry-run mode

-i, --interactive

run interactive mode

-S, --silent

don’t show commit command

-V, --version

output the version number

7. Badges

git-consistent friendly

  • Markdown

[![git-consistent friendly](https://img.shields.io/badge/git--consistent-friendly-brightgreen.svg)](https://github.com/isuke/git-consistent)
  • reStructuredText

.. image:: https://img.shields.io/badge/git--consistent-friendly-brightgreen.svg   :alt: git-consistent friendly   :target: https://github.com/isuke/git-consistent
  • AsciiDoc

image:https://img.shields.io/badge/git--consistent-friendly-brightgreen.svg["git-consistent friendly",link="https://github.com/isuke/git-consistent"]

8. TODO

8.1. Feature

8.1.1. prompt history

8.1.2. rule of 'regExp'

subject:
  type: string
  required: true
  description: 'The subject contains succinct description of the change'
  rules:
    regExp: '(fix|add|make|remove|rename)\s'
    regExpFlag: 'i'
$ git consistent --subject="Fix typo"

$ git consistent --subject="fix typo"

$ git consistent --subject="rename typo"
subject must match /(fix|add|make|remove|rename)\s/i.
You can’t perform that action at this time.