Skip to content

Instantly share code, notes, and snippets.

@mknkisk
Created March 29, 2016 01:14
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 mknkisk/381acbb8c87f67df5e3f to your computer and use it in GitHub Desktop.
Save mknkisk/381acbb8c87f67df5e3f to your computer and use it in GitHub Desktop.
#!/bin/bash
merge_commit=$(ruby -e 'print (File.readlines(ARGV[0]) & File.readlines(ARGV[1])).last' <(git rev-list --ancestry-path $1..master) <(git rev-list --first-parent $1..master))
if git show $merge_commit | grep -q 'pull request'
then
pull_request_number=$(git log -1 --format=%B $merge_commit | sed -e 's/^.*#\([0-9]*\).*$/\1/' | head -1)
url="`hub browse -u`/pull/${pull_request_number}"
echo $url
fi
open $url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment