summaryrefslogtreecommitdiff
path: root/plugins/jira
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2017-11-12 19:36:24 -0700
committerTuowen Zhao <ztuowen@gmail.com>2017-11-12 19:36:24 -0700
commit5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436 (patch)
tree2c9ab05f372ad5da84662e18a4d7e258b75d3b17 /plugins/jira
parent6bcf7764f8d8094695c7c04bb9532a0ede40ab37 (diff)
parent41eedd37005f6b3668fcebe2a5f5a26324753519 (diff)
downloadzsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.tar.gz
zsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.tar.bz2
zsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.zip
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/jira')
-rw-r--r--plugins/jira/_jira1
-rw-r--r--plugins/jira/jira.plugin.zsh26
2 files changed, 21 insertions, 6 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..0340dd7f4 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -2,13 +2,21 @@
#
# See README.md for details
-: ${JIRA_DEFAULT_ACTION:=new}
-
function jira() {
emulate -L zsh
- local action=${1:=$JIRA_DEFAULT_ACTION}
+ local action jira_url jira_prefix
+ if [[ -n "$1" ]]; then
+ action=$1
+ elif [[ -f .jira-default-action ]]; then
+ action=$(cat .jira-default-action)
+ elif [[ -f ~/.jira-default-action ]]; then
+ action=$(cat ~/.jira-default-action)
+ elif [[ -n "${JIRA_DEFAULT_ACTION}" ]]; then
+ action=${JIRA_DEFAULT_ACTION}
+ else
+ action="new"
+ fi
- local jira_url jira_prefix
if [[ -f .jira-url ]]; then
jira_url=$(cat .jira-url)
elif [[ -f ~/.jira-url ]]; then
@@ -51,8 +59,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"