Some tweaks to the Jira plugin
[x] Updating `branch` command to be compatible with git-flow style branches by removing any prefix before attempting to go to the ticket number in Jira.
[x] Removing the switch between /browse/ and /issues/ based off of the `JIRA_RAPID_BOARD` setting - as all issues are under browse now it seems.
Diff
1diff --git a/plugins/jira/README.md b/plugins/jira/README.md
2index 091dccb97dd3db8a1e265c76fa4486bc8395fd86..a211e34e0042b1f1403925353e261f2e8863700c 100644
3--- a/plugins/jira/README.md
4+++ b/plugins/jira/README.md
5@@ -23,6 +23,9 @@ jira reported [username] # queries for issues reported by a user
6 jira assigned [username] # queries for issues assigned to a user
7 jira myissues # queries for you own issues
8 jira branch # opens an existing issue matching the current branch name
9+ # The branch name may have prefixes ending in "/": "feature/MP-1234",
10+ # and also suffixes starting with "_": "MP-1234_fix_dashboard"
11+ # In both these cases, the issue opened will be "MP-1234"
12 jira ABC-123 # opens an existing issue
13 jira ABC-123 m # opens an existing issue for adding a comment
14 ```
15diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
16index ed88368cdc41bac6eeb6024fb3351dc95173e829..cb46f540b9b117d69d44c9b11f4b27303b3c5d5d 100644
17--- a/plugins/jira/jira.plugin.zsh
18+++ b/plugins/jira/jira.plugin.zsh
19@@ -67,7 +67,9 @@ function jira() {
20 if [[ "$action" == "branch" ]]; then
21 # Get name of the branch
22 issue_arg=$(git rev-parse --abbrev-ref HEAD)
23- # Split by _ character and get the first element
24+ # Strip prefixes like feature/ or bugfix/
25+ issue_arg=${issue_arg##*/}
26+ # Strip suffixes starting with _
27 issue_arg=(${(s:_:)issue_arg})
28 issue_arg=${issue_arg[1]}
29 if [[ "$issue_arg" = ${jira_prefix}* ]]; then
30@@ -87,11 +89,7 @@ function jira() {
31 else
32 echo "Opening issue #$issue"
33 fi
34- if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
35- open_command "${jira_url}/issues/${issue}${url_fragment}"
36- else
37- open_command "${jira_url}/browse/${issue}${url_fragment}"
38- fi
39+ open_command "${jira_url}/browse/${issue}${url_fragment}"
40 fi
41 }
42