Skip to content

Instantly share code, notes, and snippets.

@ezza
Created March 1, 2012 03:20
Show Gist options
  • Save ezza/1946990 to your computer and use it in GitHub Desktop.
Save ezza/1946990 to your computer and use it in GitHub Desktop.
Add beetil# prefixes to the commit message if your branch looks like it matches a beetil
# Verbose commit all changes to tracked files
alias gcav='git commit -avem "$(beetil_commit_prefix)"'
# Verbose commit specified files
# eg gcv app/views app/models/user.rb
gcv() {
git commit -vem "$(beetil_commit_prefix)" "$@"
}
# Warning: If you close the edit message window unchanged,
# your commit will go ahead because a commit message has been set.
# You need to abort the command in your terminal or
# clear the commit message before saving to abort.
# And there's always undo.
# support functions
# extracts the branch name
function plain_git_branch {
git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'
}
# extracts the part of the branch name that could be a beetil number
function beetil_number_from_git_branch {
plain_git_branch 2> /dev/null | cut -c2-9
}
# returns B#nnnnn if it looks like our branch is a beetil branch
function beetil_commit_prefix {
if [[ "$(beetil_number_from_git_branch)" =~ ^-?[0-9]+$ ]]
then
echo "B#$(beetil_number_from_git_branch) "
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment