Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner Author

commented Nov 16, 2012

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

@jsgarvin

This comment has been minimized.

Copy link

commented Apr 13, 2017

Nudge @fabpot 😄

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.