1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 22:00:08 +00:00

Clean up jira function

This commit is contained in:
Marc Cornellà 2020-03-02 23:26:52 +01:00
parent 952200044d
commit 1f6e1555f2

View file

@ -63,19 +63,24 @@ function jira() {
else else
# Anything that doesn't match a special action is considered an issue name # Anything that doesn't match a special action is considered an issue name
# but `branch` is a special case that will parse the current git branch # but `branch` is a special case that will parse the current git branch
local issue_arg issue
if [[ "$action" == "branch" ]]; then if [[ "$action" == "branch" ]]; then
local issue_arg=$(git rev-parse --abbrev-ref HEAD) # Get name of the branch
issue_arg=($(echo $issue_arg | cut -d'_' -f1)) issue_arg=$(git rev-parse --abbrev-ref HEAD)
if [[ $(echo ${issue_arg} | grep ${jira_prefix}) ]]; then # Split by _ character and get the first element
local issue="${issue_arg}" issue_arg=(${(s:_:)issue_arg})
issue_arg=${issue_arg[1]}
if [[ "$issue_arg" = ${jira_prefix}* ]]; then
issue="${issue_arg}"
else else
local issue="${jira_prefix}${issue_arg}" issue="${jira_prefix}${issue_arg}"
fi fi
else else
local issue_arg=${(U)action} issue_arg=${(U)action}
local issue="${jira_prefix}${issue_arg}" issue="${jira_prefix}${issue_arg}"
fi fi
local url_fragment=''
local url_fragment
if [[ "$2" == "m" ]]; then if [[ "$2" == "m" ]]; then
url_fragment="#add-comment" url_fragment="#add-comment"
echo "Add comment to issue #$issue" echo "Add comment to issue #$issue"