Last active
May 13, 2016 19:12
-
-
Save nyarly/bca160da9e1f02e6211646348a2ab396 to your computer and use it in GitHub Desktop.
Jira ticket ids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ⮀ jira-issues | |
| DCOPS-7200 Determine image name from source version [Development] | |
| ⮀ git jira-branch DCOPS-7200 | |
| ⮀ git commit -a | |
| <editing> | |
| DCOPS-7200 | |
| # Please enter the commit message for your changes. Lines starting | |
| ... | |
| ⮀ git push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| if [ $# -lt 1 ]; then | |
| echo "Usage: $0 <issue key>" | |
| fi | |
| path=$(git symbolic-ref HEAD) || (echo "Not on a branch"; exit 1) | |
| branch=${path#refs/heads/} | |
| issue=$1 | |
| config="branch.${branch}.jira-ticket" | |
| if git config --get-all "$config" | grep -q "^${issue}$"; then | |
| exit 0 | |
| fi | |
| git config --add "$config" "$issue" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| username=${JIRA_USERNAME:-$(git config --get jira.user)} | |
| if [ $? -ne 0 ]; then | |
| echo "Neither JIRA_USERNAME nor the jira.user git config are set" | |
| # shellcheck disable=SC2016 | |
| echo ' (Try `git config --global jira.user <your username>`)' | |
| exit 1 | |
| fi | |
| password=${JIRA_PASSWORD:-$(git config --get jira.password)} | |
| if [ $? -ne 0 ]; then | |
| echo "Neither JIRA_PASSWORD nor the jira.password git config are set" | |
| # shellcheck disable=SC2016 | |
| echo ' (Try `git config --global jira.password <your password>`)' | |
| echo " (but beware committing that config (~/.gitconfig) itself into git)" | |
| exit 1 | |
| fi | |
| jarfile=${JIRA_JARFILE:-$(git config --get jira.jarfile)} | |
| if [ $? -ne 0 ]; then | |
| echo "Neither JIRA_JARFILE nor the jira.jarfile git config are set" | |
| # shellcheck disable=SC2016 | |
| echo ' (Try `git config --global jira.jarfile <somewhere>/lib/jira-cli-5.3.0.jar`)' | |
| echo " (You'll need to download the JAR from https://bobswift.atlassian.net/wiki/display/ACLI/Downloads)" | |
| exit 1 | |
| fi | |
| server=${JIRA_SERVER:-$(git config --get jira.server)} | |
| if [ $? -ne 0 ]; then | |
| echo "Neither JIRA_SERVER nor the jira.server git config are set" | |
| # shellcheck disable=SC2016 | |
| echo ' (Try `git config --global jira.server ...`)' | |
| exit 1 | |
| fi | |
| jql=${JIRA_JQL:-$(git config --get jira.jql)} | |
| if [ $? -ne 0 ]; then | |
| echo "Neither JIRA_JQL nor the jira.jql git config are set" | |
| # shellcheck disable=SC2016 | |
| echo ' (Try `git config jira.jql ...`)' | |
| exit 1 | |
| fi | |
| extra_jql='and assignee=currentUser()' | |
| while getopts 'a' opt; do | |
| case $opt in | |
| a) extra_jql='';; | |
| esac | |
| done | |
| java -jar "$jarfile" --server "$server" --user "$username" --password "$password" --action getIssueList --columns key,summary,status --jql "$jql $extra_jql" | sed -E 's/^"|"$//g' | awk -F '"*,"*' 'NR > 2 && NF == 3 { print $1 " " $2 " [" $3 "]" }' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| file=$1 | |
| path=$(git symbolic-ref HEAD) | |
| if [ $? -ne 0 ]; then | |
| exit 0 | |
| fi | |
| current=${path#refs/heads/} | |
| jiras=$(git config --get-all "branch.${current}.jira-ticket" | sort -u) | |
| if [ $? -eq 0 ]; then | |
| tickets="" | |
| for jira_id in $jiras; do | |
| tickets+="$jira_id " | |
| done | |
| awk "/^#/ && !x {print \"tickets\"; x=1} 1" "$file" > "$file.tmp" | |
| mv "$file.tmp" "$file" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment