Skip to content

Instantly share code, notes, and snippets.

@webmozart
Created November 15, 2012 14:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmozart/4078901 to your computer and use it in GitHub Desktop.
Save webmozart/4078901 to your computer and use it in GitHub Desktop.
Script to find the merge and PR a commit occurred in
#!/bin/bash
COMMIT=$1
BRANCH=$2
if [ -z $BRANCH ]; then
BRANCH="master"
fi
perl -ne 'print if ($seen{$_} .= @ARGV) =~ /10$/' \
<(git rev-list --ancestry-path --oneline $COMMIT..$BRANCH) \
<(git rev-list --first-parent --oneline $COMMIT..$BRANCH) \
| tail -n 1
#!/bin/bash
git-find-merge $1 $2 \
| cut -d '#' -f2 \
| cut -c1-4 \
| sed 's/^/https:\/\/github.com\/symfony\/symfony\/pull\//'
@fabpot
Copy link

fabpot commented Nov 15, 2012

Here is what I have in my main .gitconfig file:

find-pr = !sh -c 'git what-branch --reference=`git rev-parse --abbrev-ref HEAD` $0 | grep \" is on \" | sed \"s/^ *//g\" | cut -d\" \" -f1 - > commit && git log -1 --format=\"%s\" `cat commit`'

@webmozart
Copy link
Author

Thanks @fabpot! Could you post the code for "what-branch" as well?

@jsgarvin
Copy link

Nudge @fabpot 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment