Skip to content

Auto replaces commit hash prefix incrementally with lucky-commit by hooking post-commit.

License

Notifications You must be signed in to change notification settings

dwisiswant0/increment-commit-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

increment-commit-hash

Auto replaces commit hash prefix incrementally with lucky-commit by hooking post-commit.

increment-commit-hash

See all demonstrations in this repository's commit history.

Installation

In order for this scenario to work, lucky_commit is required to be installed on your machine.

Local

To set up automatically in your local project:

$ curl -sL https://github.com/dwisiswant0/increment-commit-hash/raw/master/setup.sh | bash

This will add a post-commit hook for your git project. So every time you commit something, lucky_commit will run after it.

Global

Global means it applies to all your git projects and to install it you have to do-it-yourself (DIY) manually.

Add a Bash function for git alias command inside your .bash_aliases file:

git() {
	command git "${@}"
	[[ "${?}" -eq 0 ]] || return

	local COUNT=$(command git rev-list HEAD --count 2>/dev/null)
	local HASH=$(printf "%07d" "${COUNT}")

	[[ "${1}" == "commit" ]] && lucky_commit "${HASH}"
}

For the alias to trigger when you run git command, you need to either restart the terminal or evaluate directly with:

$ source $HOME/.bash_aliases

After that, the lucky_commit command will be executed in any git project after git commit subcommand w/o having to add post-commit hooks in your projects 1-by-1.

Uninstalling

To delete that alias, simply remove those git function from .bash_aliases file and restart your terminal session or unaliasing with:

$ unalias git

About

Auto replaces commit hash prefix incrementally with lucky-commit by hooking post-commit.

Topics

Resources

License

Stars

Watchers

Forks

Languages