Skip to content

A tool that makes it easy to produce structured commit messages.

License

Notifications You must be signed in to change notification settings

masukomi/git-com

Repository files navigation

README

Image

git-com

A tool that makes it easy to produce structured commit messages, that are easily customizable to your project’s need.

Example

[documentation] enhancement: adding to the spec

Documenting some more of the edge cases we'll have to handle
so that we make sure to get everything right.

Ticket: 12345

Tags: hotfix, refactoring

That commit message is made up of many interactive component parts. Some are optional. Some are required. The commit message above is a complex example made up of the following elements.

<code-section> <change-type> <commit-title>

<commit-description>

<ticket-number>

<tags>
  • <code-section> is a modifiable select list
  • <change-type> is a modifiable select list
  • <commit-title> is a simple text input
  • <commit-description> is a multi-line text input
  • <ticket-number> is an optional input that (in this configuration) will validate that the user has entered an integer.
  • <tags> is an optional multi-select list

How it Works

Once you’ve added the git-com executable to your path, typing git com instead of the usual git commit will invoke a series of prompts based on what you configure in your .git-com.yaml file at the root of your git repository. The resulting text is combined to make a structured commit message.

There can be as many, or as few elements in your configuration as you want. The only requirement is that you have at least one element in your YAML whose input will end up in the commit title.

You can also add text around the user submitted input. In the example above the <code-section> is configured with "[" as its before-string and "]" as its after-string. I just chose documentation from the select list it showed me.

Installation

Homebrew (macOS/Linux)

brew tap masukomi/homebrew-tap
brew install masukomi/homebrew-tap/git-com

Building from Source

Prerequisites

  • Go 1.21 or later
  • Git

Clone and Build

git clone https://github.com/yourusername/git-com.git
cd git-com
go build -o git-com .

Installing the executable

Move the binary to a directory in your PATH:

# Linux/macOS
sudo mv git-com /usr/local/bin/

# Or add to your personal bin directory (if that's in your PATH)
mv git-com ~/bin/

Git Integration

Because the executable is named git-com, Git will automatically recognize it as a subcommand. Once installed, you can run:

git com

This will execute the git-com tool and start presenting you with the interactive elements specified in your repo’s .git-com.yaml file.

This works because Git looks for executables named git-<command> when you type git <command>.

Usage

  1. Create a .git-com.yaml (or .git-com.yml) file in the root of your Git repository See Config File Details (or config_file_details.org locally) for detailed instructions. The .git-config.yaml in this repo is a fairly complex example.
  2. Stage your changes with git add
  3. Run git com instead of git commit
  4. Answer the interactive prompts
  5. Your commit is created with a structured message

Aborting

Press Ctrl+C or Esc at any prompt to abort without creating a commit.

About

A tool that makes it easy to produce structured commit messages.

Resources

License

Stars

Watchers

Forks

Packages

No packages published