df1b0b328983dba57b4cea123b5a05c24493ae8f
- Author
- Tom Cammann <tom.cammann@hp.com>
- Committer
- Tom Cammann <tom.cammann@hp.com>
- Date
Message
Update jira plugin to allow lookup of issues
Plugin now supports lookup of tickets by assignee and reporter
Diff
1diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
2index 3d510e4308bfa08fe430c2e6e1d9d976df1f570a..a6d08410fc22ec33c17c65c40185551a26b14c9e 100644
3--- a/plugins/jira/jira.plugin.zsh
4+++ b/plugins/jira/jira.plugin.zsh
5@@ -26,7 +26,7 @@ open_jira_issue () {
6 jira_url=$JIRA_URL
7 else
8 echo "JIRA url is not specified anywhere."
9- return 0
10+ return 1
11 fi
12
13 if [ -f .jira-prefix ]; then
14@@ -39,7 +39,9 @@ open_jira_issue () {
15
16 if [ -z "$1" ]; then
17 echo "Opening new issue"
18- $open_cmd "$jira_url/secure/CreateIssue!default.jspa"
19+ $open_cmd "${jira_url}/secure/CreateIssue!default.jspa"
20+ elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
21+ jira_query $@
22 else
23 echo "Opening issue #$1"
24 if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
25@@ -50,4 +52,39 @@ open_jira_issue () {
26 fi
27 }
28
29+jira_name () {
30+ if [[ -z "$1" ]]; then
31+ if [[ "x${JIRA_NAME}" != "x" ]]; then
32+ jira_name=${JIRA_NAME}
33+ else
34+ echo "JIRA_NAME not specified"
35+ return 1
36+ fi
37+ else
38+ jira_name=$@
39+ fi
40+}
41+
42+jira_query () {
43+ verb="$1"
44+ if [[ "${verb}" = "reported" ]]; then
45+ lookup=reporter
46+ preposition=by
47+ elif [[ "${verb}" = "assigned" ]]; then
48+ lookup=assignee
49+ preposition=to
50+ else
51+ echo "not a valid lookup $verb"
52+ return 1
53+ fi
54+ shift 1
55+ jira_name $@
56+ if [[ $? = 1 ]]; then
57+ return 1
58+ fi
59+ echo "Browsing issues ${verb} ${preposition} ${jira_name}"
60+ $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC"
61+}
62+
63 alias jira='open_jira_issue'
64+