浏览代码

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.
Josh Christopherson 4 年之前
父节点
当前提交
587000ec02
共有 2 个文件被更改,包括 7 次插入6 次删除
  1. 3 0
      plugins/jira/README.md
  2. 4 6
      plugins/jira/jira.plugin.zsh

+ 3 - 0
plugins/jira/README.md

@@ -23,6 +23,9 @@ 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
 ```

+ 4 - 6
plugins/jira/jira.plugin.zsh

@@ -67,7 +67,9 @@ function jira() {
     if [[ "$action" == "branch" ]]; then
       # Get name of the branch
       issue_arg=$(git rev-parse --abbrev-ref HEAD)
-      # Split by _ character and get the first element
+      # 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
@@ -87,11 +89,7 @@ function jira() {
     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
 }