Add shortcut for opening current branch in Jira (#6366)
Diff
1diff --git a/plugins/jira/_jira b/plugins/jira/_jira
2index 03fe6a4993fb1a92a2fb0fad73c56f03d3453cc7..890f97f4c3f5bead48b38f064580237c70c3502b 100644
3--- a/plugins/jira/_jira
4+++ b/plugins/jira/_jira
5@@ -7,6 +7,7 @@ _1st_arguments=(
6 'dashboard:open the dashboard'
7 'reported:search for issues reported by a user'
8 'assigned:search for issues assigned to a user'
9+ 'br:open the issue named after the git branch of the current directory'
10 'dumpconfig:display effective jira configuration'
11 )
1213diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
14index 67c98945787b0a0bf2512e795bb8a6eca0d9128d..fe1772cd887be7e76da7fe86eb0743554dae6ad7 100644
15--- a/plugins/jira/jira.plugin.zsh
16+++ b/plugins/jira/jira.plugin.zsh
17@@ -51,8 +51,14 @@ function jira() {
18 echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION"
19 else
20 # Anything that doesn't match a special action is considered an issue name
21- local issue_arg=$action
22- local issue="${jira_prefix}${issue_arg}"
23+ # but `branch` is a special case that will parse the current git branch
24+ if [[ "$action" == "br" ]]; then
25+ local issue_arg=$(git rev-parse --abbrev-ref HEAD)
26+ local issue="${jira_prefix}${issue_arg}"
27+ else
28+ local issue_arg=$action
29+ local issue="${jira_prefix}${issue_arg}"
30+ fi
31 local url_fragment=''
32 if [[ "$2" == "m" ]]; then
33 url_fragment="#add-comment"