Skip to content

Instantly share code, notes, and snippets.

@cvan
Created December 19, 2011 20:20
Show Gist options
  • Save cvan/1498705 to your computer and use it in GitHub Desktop.
Save cvan/1498705 to your computer and use it in GitHub Desktop.
open git commit in browser for reviews
#!/bin/sh
# Usage: `git url` or `git url <commitish>`
#
# * copies the commit's github url to your clipboard
# * prints out the log message
# * opens the bugzilla page if it found a bug number
#
# Set up the github url with `git config github.url <url>`.
# Only for the Mac.
if [[ $1 ]]; then
REV=$1
else
REV='HEAD'
fi
if [ $(git config github.url) ]; then
ROOT=$(git config github.url)
else
# You're not cvan, are you?
ROOT=$(git config remote.cvan.url | perl -pi -e 's%^.*:(.*).git%https://github.com/\1/commit%')
fi
HASH=$(git rev-parse --short $REV)
MSG=$(git log --pretty=oneline --format=%s -1 $HASH)
echo $ROOT/$HASH '\c' | pbcopy
echo $MSG
# Open the browser.
open $ROOT/$HASH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment