Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Find some Git commits and print out the subject and GitHub link
#!/bin/bash
if [ "$#" == "0" ]; then
echo "Usage: find-github-commits issue-number"
exit 1
fi
repo=$(git config --get remote.origin.url | cut -d ':' -f 2 | sed 's/....$//')
for commit in $(git rev-list --reverse origin/master)
do
if git log --format=%B -n 1 $commit | grep --silent "\?id\=$1$"; then
git log --format=%s -n 1 $commit
echo "https://github.com/$repo/commit/$(git log --format=%H -n 1 $commit | cut -c 1-10)"
echo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.