2012-09-29 05:48:18 +00:00
|
|
|
# To use: add a .jira-url file in the base of your project
|
2012-12-03 05:59:05 +00:00
|
|
|
# You can also set JIRA_URL in your .zshrc or put .jira-url in your home directory
|
|
|
|
# .jira-url in the current directory takes precedence
|
|
|
|
#
|
|
|
|
# If you use Rapid Board, set:
|
2013-06-12 17:22:47 +00:00
|
|
|
#JIRA_RAPID_BOARD="true"
|
2012-12-03 05:59:05 +00:00
|
|
|
# in you .zshrc
|
|
|
|
#
|
2012-09-29 05:48:18 +00:00
|
|
|
# Setup: cd to/my/project
|
2012-10-01 16:27:52 +00:00
|
|
|
# echo "https://name.jira.com" >> .jira-url
|
2012-09-29 05:41:30 +00:00
|
|
|
# Usage: jira # opens a new issue
|
|
|
|
# jira ABC-123 # Opens an existing issue
|
|
|
|
open_jira_issue () {
|
2013-05-27 13:23:14 +00:00
|
|
|
local open_cmd
|
|
|
|
if [[ $(uname -s) == 'Darwin' ]]; then
|
|
|
|
open_cmd='open'
|
|
|
|
else
|
|
|
|
open_cmd='xdg-open'
|
|
|
|
fi
|
|
|
|
|
2012-12-03 05:59:05 +00:00
|
|
|
if [ -f .jira-url ]; then
|
|
|
|
jira_url=$(cat .jira-url)
|
|
|
|
elif [ -f ~/.jira-url ]; then
|
|
|
|
jira_url=$(cat ~/.jira-url)
|
|
|
|
elif [[ "x$JIRA_URL" != "x" ]]; then
|
|
|
|
jira_url=$JIRA_URL
|
2012-09-29 05:41:30 +00:00
|
|
|
else
|
2012-12-03 05:59:05 +00:00
|
|
|
echo "JIRA url is not specified anywhere."
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2014-07-15 13:22:24 +00:00
|
|
|
if [ -f .jira-prefix ]; then
|
|
|
|
jira_prefix=$(cat .jira-prefix)
|
|
|
|
elif [ -f ~/.jira-prefix ]; then
|
|
|
|
jira_prefix=$(cat ~/.jira-prefix)
|
|
|
|
else
|
|
|
|
jira_prefix=""
|
|
|
|
fi
|
|
|
|
|
2012-12-03 05:59:05 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Opening new issue"
|
2013-11-12 07:55:16 +00:00
|
|
|
$open_cmd "$jira_url/secure/CreateIssue!default.jspa"
|
2012-12-03 05:59:05 +00:00
|
|
|
else
|
|
|
|
echo "Opening issue #$1"
|
2013-06-12 17:22:47 +00:00
|
|
|
if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
|
2014-07-15 13:22:24 +00:00
|
|
|
$open_cmd "$jira_url/issues/$jira_prefix$1"
|
2012-09-29 05:41:30 +00:00
|
|
|
else
|
2014-07-15 13:22:24 +00:00
|
|
|
$open_cmd "$jira_url/browse/$jira_prefix$1"
|
2012-09-29 05:41:30 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
alias jira='open_jira_issue'
|