A command line utility that easily prefixes your commit messages.
-- About --
CommitPrefix is a simple command line tool that helps you to easily prefix your commit messages. The common use case for this is tagging your commit messages with a Jira (or other issue tracking software) ticket number. The desired prefix is stored within the .git folder and picked up by a generated commit-message hook. This allows you to write your ticket number (or any other prefix) once. From then on all commit messages will be prepended with the saved prefix.
There's also a branch parse mode that allows commitPrefix to parse the current branch you're on for a valid issue numbers and use them as prefixes for your next commit. The modes can be switched back and forth arbitrarily and used along with any self defined prefixes.
Prefixes can be re-assigned or deleted at any time. Additionally, this is a git repository specific tool, meaning that stored prefixes are specific to the repository you're in.
CommitPrefix has been verified to work both from the command line as well as with GUI based Git Clients like Tower.
The actions that can be done are:
- Store an arbitrary number of commit prefixes
- Generate prefixes based on your current branch
- Delete the currently stored prefixes
- View the current mode and stored prefixes
-- Requirements --
This package uses
swift-tools-version:5.1 as a minimum requirement to build and install.
Check to see that you have Swift 5.1 or greater to meet the requirements
% swift --version
- macOS Catalina v10.15.1 or greater
-- Installation --
- Clone the repo and move to the root of the directory
% git clone https://github.com/enuance/commitPrefix.git % cd commitPrefix
- Optional Run the installer
As a good practice, please make sure to read the source code of the installer script before running it. If you do not feel comfortable running the installer, you could manually build and install it instead. If you would like to do so, follow these steps:
- Build the executable
% swift build -c release
- Install it into the local bin folder
% mv .build/release/commitPrefix /usr/local/bin
On your next Terminal session you should be able to see auto-completion and use commitPrefix.
-- Usage --
To use commitPrefix you need to have your working directory set to one that has a git repository in it.
% cd SomeGitRepository
To store a prefix
% commitPrefix SamplePrefix-001,SamplePrefix-002 # Output CommitPrefix STORED [SamplePrefix-001][SamplePrefix-002]
To change mode to branchParse
% git checkout ENG-342-SomeFeatureBranchLinkedToENG-101 % commitPrefix -b eng # Output CommitPrefix MODE BRANCH_PARSE eng
To view the current prefixes and mode
% commitPrefix # Output CommitPrefix MODE BRANCH_PARSE - branch prefixes: [SamplePrefix-001][SamplePrefix-002] - stored prefixes: [ENG-342][ENG-101]
To change back to normal mode
% commitPrefix -n # Output CommitPrefix MODE NORMAL
To delete a prefix
% commitPrefix -d # Output CommitPrefix DELETED
You can also view these command along with shortend version by using the
You may find interesting
Updated the Hook Version - 2021-01-05T23:14:39
Fixed Dependency Version Issue - 2021-01-05T22:56:57
Incorporated Tests on the CLI - 2020-01-20T19:48:09
Incorporated the Result Type 🎉 - 2020-01-13T03:42:28
Replaced all throwing methods with methods that return the result type.
Fixed the Hook Script Format and Updated the CPInterface - 2020-01-03T03:56:44
Updated the Consler Package - 2019-12-28T22:11:51
New Has Color Output on the Terminal 🎉🎉🎉 - 2019-12-25T00:55:00
Added support for terminal colors. Also improved error handling and propagation when hooks are being called from GUI clients.
Works with GUI Clients now 🎉 - 2019-12-19T03:37:59
Fixed a bug where the commitPrefix generated hooks where not being called properly when being activated from GUI based Clients.
Warning Fixes And Organization - 2019-12-17T05:22:14
Added New Version Argument 🎉🎉🎉 - 2019-12-15T00:37:09
Add and installer for the command line tool - 2019-12-14T20:18:04
The new installer will build the package in release mode and install it in the correct location for the user.
New Branch Parse Mode 🎉🎉🎉 - 2019-12-13T07:05:23
Added a New Branch Parse Mode. Also, added the ability to store multiple prefixes.