mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 08:45:39 +00:00
jira git branch tool
This commit is contained in:
parent
ae418fe5c7
commit
22fe79fa80
37
bin/jira-checkout
Executable file
37
bin/jira-checkout
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/
|
||||
# Requires the following variables to be set:
|
||||
# - ATLASSIAN_EMAIL
|
||||
# - ATLASSIAN_API_TOKEN
|
||||
# - JIRA_HOSTNAME
|
||||
# - JIRA_PROJECT
|
||||
|
||||
choose_issue() {
|
||||
jq_template='"\(.key): \(.fields.summary)"'
|
||||
query="project=$JIRA_PROJECT AND status not in (\"Done\") AND assignee=currentUser()"
|
||||
|
||||
branch_name=$(
|
||||
curl \
|
||||
--data-urlencode "jql=$query" \
|
||||
--get \
|
||||
--user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \
|
||||
--silent \
|
||||
--compressed \
|
||||
"https://$JIRA_HOSTNAME/rest/api/2/search" |
|
||||
jq ".issues[] | $jq_template" |
|
||||
sed -e 's/"\(.*\)"/\1/' |
|
||||
fzf \
|
||||
--preview='jira-details {1}' \
|
||||
--preview-window=top:wrap |
|
||||
sed -e 's/: /:/' -e 's/[^a-zA-Z0-9:]/-/g' |
|
||||
awk -F ":" '{printf "%s/%s", $1, tolower($2)}'
|
||||
)
|
||||
|
||||
echo "$branch_name"
|
||||
}
|
||||
|
||||
issue_branch=$(choose_issue)
|
||||
if [ -n "$issue_branch" ]; then
|
||||
git checkout -b "$issue_branch"
|
||||
fi
|
38
bin/jira-details
Executable file
38
bin/jira-details
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/
|
||||
# Requires the following variables to be set:
|
||||
# - ATLASSIAN_EMAIL
|
||||
# - ATLASSIAN_API_TOKEN
|
||||
# - JIRA_HOSTNAME
|
||||
# - JIRA_PROJECT (for other script)
|
||||
|
||||
issue_details() {
|
||||
jira_key=$(echo "$1" | cut -d":" -f1)
|
||||
jq_template='"'\
|
||||
'# \(.key): \(.fields.summary)\n'\
|
||||
'\n'\
|
||||
'*Created*: \(.fields.created)\n'\
|
||||
'*Status*: \(.fields.status.statusCategory.name)\n'\
|
||||
'*Reporter*: \(.fields.reporter.displayName)\n'\
|
||||
'*Priority*: \(.fields.priority.name)\n'\
|
||||
"*Epic*: https://$JIRA_HOSTNAME/browse/\(.fields.customfield_10014)\n"\
|
||||
'\n'\
|
||||
'## Link\n\n'\
|
||||
"https://$JIRA_HOSTNAME/browse/\(.key)\n"\
|
||||
'\n'\
|
||||
'## Description\n\n'\
|
||||
'\(.fields.description)'\
|
||||
'"'
|
||||
curl \
|
||||
--get \
|
||||
--user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \
|
||||
--silent \
|
||||
--compressed \
|
||||
"https://$JIRA_HOSTNAME/rest/api/2/issue/$jira_key" |
|
||||
jq "$jq_template" |
|
||||
xargs printf |
|
||||
bat -l md --color always --style plain
|
||||
}
|
||||
|
||||
issue_details "$1"
|
Loading…
Reference in New Issue
Block a user