summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarryd Tilbrook <jrad.tilbrook@gmail.com>2017-11-01 21:04:41 +0800
committerRobby Russell <robby@planetargon.com>2017-11-01 06:04:41 -0700
commit529a12fac857efbfa749998ed872d668ff51d15d (patch)
tree3cefafea25baeea7da8fab789806936ce1c3ac57
parente8e7bf3b892ef69aac97c171d02b4b026322dcec (diff)
downloadzsh-529a12fac857efbfa749998ed872d668ff51d15d.tar.gz
zsh-529a12fac857efbfa749998ed872d668ff51d15d.tar.bz2
zsh-529a12fac857efbfa749998ed872d668ff51d15d.zip
Add shortcut for opening current branch in Jira (#6366)
-rw-r--r--plugins/jira/_jira1
-rw-r--r--plugins/jira/jira.plugin.zsh10
2 files changed, 9 insertions, 2 deletions
diff --git a/plugins/jira/_jira b/plugins/jira/_jira
index 03fe6a499..890f97f4c 100644
--- a/plugins/jira/_jira
+++ b/plugins/jira/_jira
@@ -7,6 +7,7 @@ _1st_arguments=(
'dashboard:open the dashboard'
'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user'
+ 'br:open the issue named after the git branch of the current directory'
'dumpconfig:display effective jira configuration'
)
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index 67c989457..fe1772cd8 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -51,8 +51,14 @@ function jira() {
echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION"
else
# Anything that doesn't match a special action is considered an issue name
- local issue_arg=$action
- local issue="${jira_prefix}${issue_arg}"
+ # but `branch` is a special case that will parse the current git branch
+ if [[ "$action" == "br" ]]; then
+ local issue_arg=$(git rev-parse --abbrev-ref HEAD)
+ local issue="${jira_prefix}${issue_arg}"
+ else
+ local issue_arg=$action
+ local issue="${jira_prefix}${issue_arg}"
+ fi
local url_fragment=''
if [[ "$2" == "m" ]]; then
url_fragment="#add-comment"