summaryrefslogtreecommitdiff
path: root/plugins/jira
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jira')
-rw-r--r--plugins/jira/README.md5
-rw-r--r--plugins/jira/_jira1
-rw-r--r--plugins/jira/jira.plugin.zsh36
3 files changed, 31 insertions, 11 deletions
diff --git a/plugins/jira/README.md b/plugins/jira/README.md
index a934ae68c..a5633af77 100644
--- a/plugins/jira/README.md
+++ b/plugins/jira/README.md
@@ -19,9 +19,14 @@ jira # performs the default action
jira new # opens a new issue
jira dashboard # opens your JIRA dashboard
+jira tempo # opens your JIRA Tempo
jira reported [username] # queries for issues reported by a user
jira assigned [username] # queries for issues assigned to a user
+jira myissues # queries for you own issues
jira branch # opens an existing issue matching the current branch name
+ # The branch name may have prefixes ending in "/": "feature/MP-1234",
+ # and also suffixes starting with "_": "MP-1234_fix_dashboard"
+ # In both these cases, the issue opened will be "MP-1234"
jira ABC-123 # opens an existing issue
jira ABC-123 m # opens an existing issue for adding a comment
```
diff --git a/plugins/jira/_jira b/plugins/jira/_jira
index d64614233..1ac3eeda3 100644
--- a/plugins/jira/_jira
+++ b/plugins/jira/_jira
@@ -5,6 +5,7 @@ local -a _1st_arguments
_1st_arguments=(
'new:create a new issue'
'dashboard:open the dashboard'
+ 'tempo:open the tempo'
'reported:search for issues reported by a user'
'assigned:search for issues assigned to a user'
'branch:open the issue named after the git branch of the current directory'
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index 052481a60..22807e0ae 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -43,7 +43,10 @@ function jira() {
echo "Opening new issue"
open_command "${jira_url}/secure/CreateIssue!default.jspa"
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
- _jira_query $@
+ _jira_query ${@:-$action}
+ elif [[ "$action" == "myissues" ]]; then
+ echo "Opening my issues"
+ open_command "${jira_url}/issues/?filter=-1"
elif [[ "$action" == "dashboard" ]]; then
echo "Opening dashboard"
if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
@@ -51,6 +54,9 @@ function jira() {
else
open_command "${jira_url}/secure/Dashboard.jspa"
fi
+ elif [[ "$action" == "tempo" ]]; then
+ echo "Opening tempo"
+ open_command "${jira_url}/secure/Tempo.jspa"
elif [[ "$action" == "dumpconfig" ]]; then
echo "JIRA_URL=$jira_url"
echo "JIRA_PREFIX=$jira_prefix"
@@ -60,25 +66,33 @@ function jira() {
else
# 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
+ local issue_arg issue
if [[ "$action" == "branch" ]]; then
- local issue_arg=$(git rev-parse --abbrev-ref HEAD)
- local issue="${jira_prefix}${issue_arg}"
+ # Get name of the branch
+ issue_arg=$(git rev-parse --abbrev-ref HEAD)
+ # Strip prefixes like feature/ or bugfix/
+ issue_arg=${issue_arg##*/}
+ # Strip suffixes starting with _
+ issue_arg=(${(s:_:)issue_arg})
+ issue_arg=${issue_arg[1]}
+ if [[ "$issue_arg" = ${jira_prefix}* ]]; then
+ issue="${issue_arg}"
+ else
+ issue="${jira_prefix}${issue_arg}"
+ fi
else
- local issue_arg=$action
- local issue="${jira_prefix}${issue_arg}"
+ issue_arg=${(U)action}
+ issue="${jira_prefix}${issue_arg}"
fi
- local url_fragment=''
+
+ local url_fragment
if [[ "$2" == "m" ]]; then
url_fragment="#add-comment"
echo "Add comment to issue #$issue"
else
echo "Opening issue #$issue"
fi
- if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
- open_command "${jira_url}/issues/${issue}${url_fragment}"
- else
- open_command "${jira_url}/browse/${issue}${url_fragment}"
- fi
+ open_command "${jira_url}/browse/${issue}${url_fragment}"
fi
}