caf667fb309eda77a6ecec44ce1f8a21280b6fb7

Author
Andrew Janke <andrew@apjanke.net>
Committer
Andrew Janke <andrew@apjanke.net>
Date

Message

Merge branch PR 4132 into jira-prefix-and-help-and-stuff

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
  2index 9a89327028a8acb9d36dbcd10a7eaf343f29a41f..0059249e28f4ef4241ffe49fc5ffd7ecc998c258 100644
  3--- a/plugins/jira/jira.plugin.zsh
  4+++ b/plugins/jira/jira.plugin.zsh
  5@@ -1,6 +1,7 @@
  6 # To use: add a .jira-url file in the base of your project
  7 #         You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
  8-#         .jira-url in the current directory takes precedence
  9+#         .jira-url in the current directory takes precedence. The same goes with .jira-prefix
 10+#         and JIRA_PREFIX.
 11 #
 12 # If you use Rapid Board, set:
 13 #JIRA_RAPID_BOARD="true"
 14@@ -15,17 +16,20 @@ open_jira_issue () {
 15     jira_url=$(cat .jira-url)
 16   elif [ -f ~/.jira-url ]; then
 17     jira_url=$(cat ~/.jira-url)
 18-  elif [[ "x$JIRA_URL" != "x" ]]; then
 19-    jira_url=$JIRA_URL
 20+  elif [[ "${JIRA_URL}" != "" ]]; then
 21+    jira_url=${JIRA_URL}
 22   else
 23     echo "JIRA url is not specified anywhere."
 24     return 1
 25   fi
 26 
 27+  local jira_prefix
 28   if [ -f .jira-prefix ]; then
 29     jira_prefix=$(cat .jira-prefix)
 30   elif [ -f ~/.jira-prefix ]; then
 31     jira_prefix=$(cat ~/.jira-prefix)
 32+  elif [[ "${JIRA_PREFIX}" != "" ]]; then
 33+    jira_prefix=${JIRA_PREFIX}
 34   else
 35     jira_prefix=""
 36   fi
 37@@ -35,7 +39,7 @@ open_jira_issue () {
 38     open_command "${jira_url}/secure/CreateIssue!default.jspa"
 39   elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then
 40     jira_query $@
 41-  else 
 42+  else
 43     local addcomment=''
 44     if [[ "$2" == "m" ]]; then
 45       addcomment="#add-comment"
 46@@ -43,18 +47,17 @@ open_jira_issue () {
 47     else
 48       echo "Opening issue #$1"
 49     fi
 50-    
 51-    if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
 52-      open_command  "$jira_url/issues/$jira_prefix$1$addcomment"
 53+    if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
 54+      open_command "${jira_url}/issues/${jira_prefix}${1}${addcomment}"
 55     else
 56-      open_command  "$jira_url/browse/$jira_prefix$1$addcomment"
 57+      open_command "${jira_url}/browse/${jira_prefix}${1}${addcomment}"
 58     fi
 59   fi
 60 }
 61 
 62 jira_name () {
 63   if [[ -z "$1" ]]; then
 64-    if [[ "x${JIRA_NAME}" != "x" ]]; then
 65+    if [[ "${JIRA_NAME}" != "" ]]; then
 66       jira_name=${JIRA_NAME}
 67     else
 68       echo "JIRA_NAME not specified"
 69@@ -66,24 +69,25 @@ jira_name () {
 70 }
 71 
 72 jira_query () {
 73-    verb="$1"
 74-    if [[ "${verb}" = "reported" ]]; then
 75-      lookup=reporter
 76-      preposition=by
 77-    elif [[ "${verb}" = "assigned" ]]; then
 78-      lookup=assignee
 79-      preposition=to
 80-    else
 81-      echo "not a valid lookup $verb"
 82-      return 1
 83-    fi
 84-    shift 1
 85-    jira_name $@
 86-    if [[ $? = 1 ]]; then
 87-        return 1
 88-    fi
 89-    echo "Browsing issues ${verb} ${preposition} ${jira_name}"
 90-    open_command "${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"
 91+  local verb="$1"
 92+  local jira_name lookup preposition
 93+  if [[ "${verb}" = "reported" ]]; then
 94+    lookup=reporter
 95+    preposition=by
 96+  elif [[ "${verb}" = "assigned" ]]; then
 97+    lookup=assignee
 98+    preposition=to
 99+  else
100+    echo "not a valid lookup $verb"
101+    return 1
102+  fi
103+  shift 1
104+  jira_name $@