From 2f6d79b75dadc98a80cf9e546c4eae0a7cfd30e5 Mon Sep 17 00:00:00 2001 From: Matthew Manuel Date: Sun, 24 Dec 2017 18:59:04 +1100 Subject: [PATCH 1/4] Uppercase the issue in open issue command in the JIRA plugin --- plugins/jira/jira.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index e706948e9..13de0f437 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -67,7 +67,7 @@ function jira() { local issue_arg=$(git rev-parse --abbrev-ref HEAD) local issue="${jira_prefix}${issue_arg}" else - local issue_arg=$action + local issue_arg=${(U)action} local issue="${jira_prefix}${issue_arg}" fi local url_fragment='' From 952200044d4078cbc5f45e4cd9228347c57e80b9 Mon Sep 17 00:00:00 2001 From: RoToRx88 Date: Tue, 26 Jun 2018 15:19:22 +0200 Subject: [PATCH 2/4] Better support for branch name Enable to get issue from branch prefixed with it and delimited by '_' --- plugins/jira/jira.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 13de0f437..9e7cf2b88 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -65,7 +65,12 @@ function jira() { # but `branch` is a special case that will parse the current git branch if [[ "$action" == "branch" ]]; then local issue_arg=$(git rev-parse --abbrev-ref HEAD) - local issue="${jira_prefix}${issue_arg}" + issue_arg=($(echo $issue_arg | cut -d'_' -f1)) + if [[ $(echo ${issue_arg} | grep ${jira_prefix}) ]]; then + local issue="${issue_arg}" + else + local issue="${jira_prefix}${issue_arg}" + fi else local issue_arg=${(U)action} local issue="${jira_prefix}${issue_arg}" From 1f6e1555f28e81e63ab0f3d213207975d75892f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Mon, 2 Mar 2020 23:26:52 +0100 Subject: [PATCH 3/4] Clean up jira function --- plugins/jira/jira.plugin.zsh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 9e7cf2b88..ed88368cd 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -63,19 +63,24 @@ function jira() { else # Anything that doesn't match a special action is considered an issue name # but `branch` is a special case that will parse the current git branch + local issue_arg issue if [[ "$action" == "branch" ]]; then - local issue_arg=$(git rev-parse --abbrev-ref HEAD) - issue_arg=($(echo $issue_arg | cut -d'_' -f1)) - if [[ $(echo ${issue_arg} | grep ${jira_prefix}) ]]; then - local issue="${issue_arg}" + # Get name of the branch + issue_arg=$(git rev-parse --abbrev-ref HEAD) + # Split by _ character and get the first element + issue_arg=(${(s:_:)issue_arg}) + issue_arg=${issue_arg[1]} + if [[ "$issue_arg" = ${jira_prefix}* ]]; then + issue="${issue_arg}" else - local issue="${jira_prefix}${issue_arg}" + issue="${jira_prefix}${issue_arg}" fi else - local issue_arg=${(U)action} - local issue="${jira_prefix}${issue_arg}" + issue_arg=${(U)action} + issue="${jira_prefix}${issue_arg}" fi - local url_fragment='' + + local url_fragment if [[ "$2" == "m" ]]; then url_fragment="#add-comment" echo "Add comment to issue #$issue" From 587000ec024b800d968ede14fc01ed28818e4b32 Mon Sep 17 00:00:00 2001 From: Josh Christopherson Date: Thu, 27 Jun 2019 14:16:57 -0500 Subject: [PATCH 4/4] 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. --- plugins/jira/README.md | 3 +++ plugins/jira/jira.plugin.zsh | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/jira/README.md b/plugins/jira/README.md index 091dccb97..a211e34e0 100644 --- a/plugins/jira/README.md +++ b/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 ``` diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ed88368cd..cb46f540b 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/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 }