Last active
June 20, 2018 20:41
-
-
Save timgthomas/5da411424a92a608ec12f750eb816267 to your computer and use it in GitHub Desktop.
Jira Issue–Aware Commit Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# APP-1337 $ commit 'foo' | |
# > 'APP-1337: foo' | |
function commit { | |
local message=$1 | |
local branch=$(git symbolic-ref HEAD) | |
local regex="([A-Z]+-[0-9]+)" | |
if [[ $branch =~ $regex ]] | |
then | |
git add -A && git commit -m "${match[1]}: ${message}" # zsh | |
# git add -A && git commit -m "${BASH_REMATCH[1]}: ${message}" # bash | |
else | |
git add -A && git commit -m "${message}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment