Skip to content

Instantly share code, notes, and snippets.

@ariya
Created September 19, 2012 05:37
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 ariya/3747861 to your computer and use it in GitHub Desktop.
Save ariya/3747861 to your computer and use it in GitHub Desktop.
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