39e5c9a6d7a88feb570f340ca52e87c8ff8cce61

Author
Brian Hartvigsen <brian.andrew@brianandjenny.com>
Committer
Brian Hartvigsen <brian.andrew@brianandjenny.com>
Date

Message

Backwards Compatible Jira URLs #1378

Adds support for Rapid Board without breaking backwards compatibility (like #1378)
Allows JIRA url to be set in .zshrc, current directory, and/or home directory.

Diff

 1diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
 2index de8d1052952acd5fc4934e290730a4813f6c590e..b91f93c9565620f53094880cef5bc0469ab3250f 100644
 3--- a/plugins/jira/jira.plugin.zsh
 4+++ b/plugins/jira/jira.plugin.zsh
 5@@ -1,20 +1,36 @@
 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+#
10+# If you use Rapid Board, set:
11+#JIRA_RAPID_BOARD="yes"
12+# in you .zshrc
13+#
14 # Setup: cd to/my/project
15 #        echo "https://name.jira.com" >> .jira-url
16 # Usage: jira           # opens a new issue
17 #        jira ABC-123   # Opens an existing issue
18 open_jira_issue () {
19-  if [ ! -f .jira-url ]; then
20-    echo "There is no .jira-url file in the current directory..."
21-    return 0;
22+  if [ -f .jira-url ]; then
23+    jira_url=$(cat .jira-url)
24+  elif [ -f ~/.jira-url ]; then
25+    jira_url=$(cat ~/.jira-url)
26+  elif [[ "x$JIRA_URL" != "x" ]]; then
27+    jira_url=$JIRA_URL
28   else
29-    jira_url=$(cat .jira-url);
30-    if [ -z "$1" ]; then
31-      echo "Opening new issue";
32-      `open $jira_url/secure/CreateIssue!default.jspa`;
33+    echo "JIRA url is not specified anywhere."
34+    return 0
35+  fi
36+
37+  if [ -z "$1" ]; then
38+    echo "Opening new issue"
39+    `open $jira_url/secure/CreateIssue!default.jspa`
40+  else
41+    echo "Opening issue #$1"
42+    if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
43+      `open $jira_url/issues/$1`
44     else
45-      echo "Opening issue #$1";
46-      `open $jira_url/browse/$1`;
47+      `open $jira_url/browse/$1`
48     fi
49   fi
50 }