Skip to content

Instantly share code, notes, and snippets.

@kswedberg
Created December 2, 2012 18:41
Show Gist options
  • Save kswedberg/4190376 to your computer and use it in GitHub Desktop.
Save kswedberg/4190376 to your computer and use it in GitHub Desktop.
commit pull request
cipreq() {
if [ -z "$1" ]
then
echo `git log -1 --no-merges --pretty=format:'git commit -a --author="'"%an <%aE>"'" --message="'"%s %b"'"'`
return 1
fi
AUTHOR=$1
if [ -z "$2" ]
then
MSG=""
else
MSG="--grep=${2}"
fi
echo `git log -1 ${MSG} --author="${AUTHOR}" --no-merges --pretty=format:'git commit -a --author="'"%an <%aE>"'" --message="'"%s %b"'"'`
}
@kswedberg
Copy link
Author

Usage:

This simple function is meant to help those who want merge pull requests into a repo and give proper attribution to the pull request's author. Run the cipreq command on the command line to get a git commit line that you can copy and paste back into the terminal.

If you just type cipreq alone, it will use the last commit (by date) to the repo. If you add the author's name, or any part of that name, to the command, it will use the last commit by that author. For example, entering cipreq Karl will give you the copy/paste line using the author and message of the last commit by someone with "Karl" in his name.

@kswedberg
Copy link
Author

If the author committed again after sending the pull request and that other commit was merged in, you can specify a distinctive word within the commit message that you're targeting. It would look like this:

cipreq Karl somethingFromCommit

This is starting to feel hackish. I wish I knew how to do command-line arguments of the -- variety so we could do something like cipreq --author=Karl --msg=somethingFromCommit

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