Skip to content

Instantly share code, notes, and snippets.

@dedeibel
Last active May 23, 2017 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dedeibel/9dc08833d7324507ed9cadab2f2afece to your computer and use it in GitHub Desktop.
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
# 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
@dedeibel
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment