diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2023-01-17 12:46:15 +0100 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2023-01-17 12:46:15 +0100 |
commit | db7efd2336e4dbe6abf321b00dbc11bc5afb1355 (patch) | |
tree | 720a58ff82bf0a0e0167594131f872d453b1828e /plugins/jira | |
parent | 04b8c052e5b624873b352889423c753ed1baf9c4 (diff) | |
parent | 8f0e296dbf27026ea0515ebae0d3cc41f236ecdc (diff) | |
download | zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.gz zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.bz2 zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.zip |
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'plugins/jira')
-rw-r--r-- | plugins/jira/README.md | 43 | ||||
-rw-r--r-- | plugins/jira/_jira | 1 | ||||
-rw-r--r-- | plugins/jira/jira.plugin.zsh | 24 |
3 files changed, 48 insertions, 20 deletions
diff --git a/plugins/jira/README.md b/plugins/jira/README.md index a5633af77..d78ea15a4 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -14,22 +14,31 @@ In this document, "JIRA" refers to the JIRA issue tracking server, and `jira` re This plugin supplies one command, `jira`, through which all its features are exposed. Most forms of this command open a JIRA page in your web browser. -``` -jira # performs the default action - -jira new # opens a new issue -jira dashboard # opens your JIRA dashboard -jira tempo # opens your JIRA Tempo -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 -``` +## Commands + +| Command | Description | +| :------------ | :-------------------------------------------------------- | +| `jira` | Performs the default action | +| `jira new` | Opens a new Jira issue dialogue | +| `jira ABC-123` | Opens an existing issue | +| `jira ABC-123 m` | Opens an existing issue for adding a comment | +| `jira dashboard [rapid_view]` | # opens your JIRA dashboard | +| `jira mine` | Queries for your own issues | +| `jira tempo` | Opens your JIRA Tempo | +| `jira reported [username]` | Queries for issues reported by a user | +| `jira assigned [username]` | Queries for issues assigned to a user | +| `jira branch` | Opens an existing issue matching the current branch name | + + +### Jira Branch usage notes + +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" + +This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234", +"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234". + + #### Debugging usage #### @@ -62,7 +71,9 @@ echo "https://jira.atlassian.com" >> .jira-url * `$JIRA_NAME` - Your JIRA username; used as the default user for `assigned`/`reported` searches * `$JIRA_PREFIX` - Prefix added to issue ID arguments * `$JIRA_RAPID_BOARD` - Set to `true` if you use Rapid Board +* `$JIRA_RAPID_VIEW` - Set the default rapid view; it doesn't work if `$JIRA_RAPID_BOARD` is set to false * `$JIRA_DEFAULT_ACTION` - Action to do when `jira` is called with no arguments; defaults to "new" +* `$JIRA_TEMPO_PATH` - Your JIRA tempo url path; defaults to "/secure/Tempo.jspa" ### Browser ### diff --git a/plugins/jira/_jira b/plugins/jira/_jira index 1ac3eeda3..0e37b7e9d 100644 --- a/plugins/jira/_jira +++ b/plugins/jira/_jira @@ -4,6 +4,7 @@ local -a _1st_arguments _1st_arguments=( 'new:create a new issue' + 'mine:open my issues' 'dashboard:open the dashboard' 'tempo:open the tempo' 'reported:search for issues reported by a user' diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 22807e0ae..e789fce92 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -44,25 +44,31 @@ function jira() { open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then _jira_query ${@:-$action} - elif [[ "$action" == "myissues" ]]; then + elif [[ "$action" == "mine" ]]; then echo "Opening my issues" open_command "${jira_url}/issues/?filter=-1" elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then - open_command "${jira_url}/secure/RapidBoard.jspa" + _jira_rapid_board ${@} else open_command "${jira_url}/secure/Dashboard.jspa" fi elif [[ "$action" == "tempo" ]]; then echo "Opening tempo" - open_command "${jira_url}/secure/Tempo.jspa" + if [[ -n "$JIRA_TEMPO_PATH" ]]; then + open_command "${jira_url}${JIRA_TEMPO_PATH}" + else + open_command "${jira_url}/secure/Tempo.jspa" + fi elif [[ "$action" == "dumpconfig" ]]; then echo "JIRA_URL=$jira_url" echo "JIRA_PREFIX=$jira_prefix" echo "JIRA_NAME=$JIRA_NAME" + echo "JIRA_RAPID_VIEW=$JIRA_RAPID_VIEW" echo "JIRA_RAPID_BOARD=$JIRA_RAPID_BOARD" echo "JIRA_DEFAULT_ACTION=$JIRA_DEFAULT_ACTION" + echo "JIRA_TEMPO_PATH=$JIRA_TEMPO_PATH" 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 @@ -75,7 +81,7 @@ function jira() { # Strip suffixes starting with _ issue_arg=(${(s:_:)issue_arg}) issue_arg=${issue_arg[1]} - if [[ "$issue_arg" = ${jira_prefix}* ]]; then + if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then issue="${issue_arg}" else issue="${jira_prefix}${issue_arg}" @@ -107,6 +113,16 @@ Valid options, in order of precedence: EOF } +function _jira_rapid_board() { + rapid_view=${2:=$JIRA_RAPID_VIEW} + + if [[ -z $rapid_view ]]; then + open_command "${jira_url}/secure/RapidBoard.jspa" + else + open_command "${jira_url}/secure/RapidBoard.jspa?rapidView=$rapid_view" + fi +} + function _jira_query() { emulate -L zsh local verb="$1" |