ColCh / git-commit-msg

Git hook which would add emoji and infer commit context (conventional commits)

Repository from Github https://github.comColCh/git-commit-msgRepository from Github https://github.comColCh/git-commit-msg

git-commit-msg

Adds emojis and infers commit context for people who use conventional commits

  1. install it as git hooks: prepare-commit-msg and commit-msg
  2. follow git conventional commits: https://www.conventionalcommits.org/en/v1.0.0-beta.2/
  3. ???
  4. PROFIT

demo

Open GIF spoiler

demo on streamable: https://streamable.com/n0u5p webm: https://github.com/ColCh/git-commit-msg/blob/master/demo/demo.webm

more info

This hook currently does that:

  1. Prepend emoji before git commit type. Predefined types are here:

    git-commit-msg/index.js

    Lines 13 to 24 in 24ee7be

    const commitTypeToEmoji = {
    chore: 'πŸ˜’',
    docs: 'πŸ“',
    feat: '⭐',
    fix: 'πŸ› ',
    refactor: 'β™»',
    style: 'πŸ’„',
    test: 'πŸ”',
    type: '🏷',
    perf: '⚑',
    ci: 'πŸ€–',
    };
  2. Mark words with predefined emoji defined here:

    git-commit-msg/index.js

    Lines 26 to 43 in 24ee7be

    const markWordsWithEmoji = {
    update: '⬆ ',
    add: 'βž•',
    remove: 'βž–',
    change: 'πŸ”',
    rename: 'πŸ”',
    package: 'πŸ“¦',
    deploy: 'πŸ“¦',
    fix: 'πŸ› ',
    webpack: ' 🎁',
    increase: 'πŸ“ˆ ',
    decrease: ' πŸ“‰',
    copy: ' πŸ“‹',
    config: 'βš™οΈ',
    configure: 'βš™οΈ',
    optimize: ' πŸš€',
    typo: ' πŸ“',
    };
    . Example:
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "add" should match snapshot 1`] = `"some msg βž• add some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "change" should match snapshot 1`] = `"some msg πŸ” change some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "config" should match snapshot 1`] = `"some msg βš™οΈ config some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "configure" should match snapshot 1`] = `"some msg βš™οΈ configure some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "copy" should match snapshot 1`] = `"some msg πŸ“‹ copy some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "decrease" should match snapshot 1`] = `"some msg πŸ“‰ decrease some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "deploy" should match snapshot 1`] = `"some msg πŸ“¦ deploy some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "fix" should match snapshot 1`] = `"some msg πŸ›  fix some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "increase" should match snapshot 1`] = `"some msg πŸ“ˆ increase some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "optimize" should match snapshot 1`] = `"some msg πŸš€ optimize some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "package" should match snapshot 1`] = `"some msg πŸ“¦ package some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "remove" should match snapshot 1`] = `"some msg βž– remove some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "rename" should match snapshot 1`] = `"some msg πŸ” rename some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "typo" should match snapshot 1`] = `"some msg πŸ“ typo some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "update" should match snapshot 1`] = `"some msg ⬆ update some msg"`;
    exports[`main test for git-commit-msg mark words with emoji per-word tests given word "webpack" should match snapshot 1`] = `"some msg 🎁 webpack some msg"`;
  3. Try to infer git commit context. Example:
    # Found 3 contexts
    # * modified-file
    # * deleted-file
    # * new-file

install

yarn global add @colch/git-commit-msg

add git-commit-msg into prepare-commit-msg and commit-msg hooks:

git-commit-msg $1

to appear like that:

options

pass it like env variables

  • GIT_COMMIT_MSG_HOOK_SKIP_ADDING_EMOJIS - completely disable emojis

  • GIT_COMMIT_MSG_HOOK_SKIP_AUTO_SUGGEST - disable emoji auto suggest

About

Git hook which would add emoji and infer commit context (conventional commits)


Languages

Language:JavaScript 100.0%