Created
March 22, 2022 21:13
-
-
Save maxRN/671c9cfd977473ab5113d8f95544ae59 to your computer and use it in GitHub Desktop.
Get Jira issues for file from 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
#!/bin/bash | |
JIRA_BASE_URL="https:\/\/your.jira.com\/browse\/" | |
# --follow lists all commits for the particular file, even through renames | |
# %B is short for commit subject line + body | |
COMMIT_MESSAGES=$(git log --pretty=format:%B --follow -- $1) | |
# matches Jira issue keys, e.g. JIRA-123 | |
PATTERN='([[:upper:]]+-[[:digit:]]+)' | |
# -e is pattern to match against; -E means to interpret regex as extended pattern; -o only prints the matched words | |
grep -E -e ${PATTERN} -o <<< ${COMMIT_MESSAGES} | sed -e "s/^/${JIRA_BASE_URL}/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment