Last active
May 23, 2017 10:01
-
-
Save dedeibel/9dc08833d7324507ed9cadab2f2afece to your computer and use it in GitHub Desktop.
fish function that prepares a git commit command with message containing the jira ticket number
This file contains hidden or 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
# save as ~/.config/fish/functions/commit.fish | |
# Use: | |
# Assuming you are in a git repository of a bitbucket / jira branch using the atlassian jira git flow conventions | |
# example "feature/EXP-1337-cool-new-feature | |
# | |
# MAC USERS CHANGE "sed -r" to "sed -E" | |
# | |
# > commit | |
# will expand to | |
# > git commit -m 'EXP-1337: ' | |
# resting the cursor just before the last quote | |
# | |
set _ticket (git rev-parse --abbrev-ref HEAD 2>/dev/null | \ | |
sed -r 's#^(feature|hotfix|bugfix|experiment)/?([[:alpha:]]+-[[:digit:]]+).*$#\2#') | |
commandline -r "git commit -m '$_ticket: '" | |
commandline -C (expr (commandline -C) - 1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please also see https://gist.github.com/MaZderMind/1c79bf1be1a5bf92c3a10608e8710c3c#file-commit-fish