Skip to content

Instantly share code, notes, and snippets.

@gpr
Last active July 30, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpr/18b609ec3d823ea3377890ffa4c6dff1 to your computer and use it in GitHub Desktop.
Save gpr/18b609ec3d823ea3377890ffa4c6dff1 to your computer and use it in GitHub Desktop.
[Show commits that contain a reference to a Jira issue] #jira #git
#!/usr/bin/env bash
#
# usage: git-log-show-jira-commit.bash <JIRA_KEY>
#
JIRA_KEY=${1:?}
REGEX="^.*(${JIRA_KEY}-\d+).*\$"
git log -P --grep="${REGEX}" --pretty=%H | while read line
do
p=$(git log -1 $line --pretty=%B | perl -ne "/${REGEX}/ and print \"\$1 \"")
git log -1 $line --pretty="$p: %h %s"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment