Last active
July 26, 2023 21:16
-
-
Save wyattisimo/6391548fe5624bd8f2299906dfb41d63 to your computer and use it in GitHub Desktop.
shell script to output list of Jira tickets based on git commit history
This file contains 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 | |
# Git Jira Tickets | |
# Outputs a list of Jira ticket numbers from a git log | |
# Usage: gjt <since_commit> | |
commit_messages=$(git log --merges --pretty=format:'%h %s' $1^..HEAD | sed "s/ /SPACE_DELIMITER/g") | |
lines=() | |
i=0 | |
for msg in $commit_messages; | |
do | |
hash=$(echo $msg | egrep -o "^[a-f0-9]+") | |
branch=$(echo $msg | egrep -o "(branch|from)SPACE_DELIMITER'?[a-zA-Z0-9/_-]+'?" | sed -E "s/branch|from|SPACE_DELIMITER|'//g") | |
ticket=$(echo $msg | egrep -o "\[?[a-zA-Z]{2}-[0-9]+\]?" | sed 's/[][]//g' | tr [a-z] [A-Z]) | |
lines[$i]="- [[$ticket](https://salido.atlassian.net/browse/$ticket)] $hash $branch" | |
((i++)) | |
done | |
printf "%s\n" "${lines[@]}" | sort -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment