git commit has a verbose flag that outputs the diff of the changes you're about to commit. Here, I'm adding the flag that does the same thing: output the diff of the changes that you're going to submit a pull request for.
The diff for git commit -v is not in comments and I think that's done intentionally for text editors to color code the message. So, I did a search for how git knows not to include the diff in the commit message and found this. I've never coded in C but it seems like it searches for diff --git text and ignores everything below it. That's how I implemented it in pull request.
git commit -v
However, that patch also shows the issues with the implementation and how they want to change it to a 'special scissor separator line'. We can change this implementation to use a 'special line' as well but it's not the current git behavior so I didn't do that.
Let me know what you think!
Add verbose flag to pull-request that resembles `git commit -v`
I think this is good stuff. But, the new test for the feature is lacking. Specifically, it doesn't verify that the proper diff gets extracted from git. For that to happen, you would need to make actual commits in the test setup and "push" them to appropriate remotes before invoking hub pull-request. However, I admit that this is tricky and something we haven't done in tests before, and I can try to do this myself if you don't figure it out in the meantime.
Make actualy commits and "push" them to remotes to better test verbos…
…e flag in `git pull-request`
Use grep to see if the proper diff is included in the pull request me…
@mislav Thanks for the feedback! I completely agree with you that the tests are lacking in that we don't verify the diff.
I attempted to follow your steps to get in a state where a diff would be displayed. I also attempted to "test" the diff as well (got help here).
I'm not sure if I like what I have so far. My main hiccup is testing the diff because I couldn't find a way to read the contents of PULLREQ_EDITMSG before it was created. But I hope this is the right direction.
@ivantsepp Sorry that this hasn't made it in.
Closing this PR as it won't apply anymore since we nuked the Ruby implementation and replaced it with Go. #642