How I've started managing GitHub pulls

I don't like GitHub's pull interface. They make merge commits, which suck. And I want to work from the command line, not the web site.

When I noticed that I was losing on the scoreboard, I wrote a quick and dirty script to list open pull requests for a repository from the command line: github-list-pulls.

You'll need a GitHub token, as I describe in "How to move CPAN RT tickets to Github". And you'll need to put it and your user name in your ~/.gitconfig file. Or you need to edit my code to store those another way.

It works like this:

$ cd ~/git/path-iterator-rule
$ github-list-pulls
dagolden/path-iterator-rule:

  2013-02-28T21:48:19Z Implementation for line_match and contents_match rules

    Includes test cases and documentation.

    Link: https://github.com/dagolden/path-iterator-rule/pull/8

    git-fetch-branch git://github.com/tobyink/path-iterator-rule.git master

That last line lets me copy and paste the command for another script I have that creates a local review branch of a pull: git-fetch-branch.

Here's how that one works:

$ git-fetch-branch git://github.com/tobyink/path-iterator-rule.git master
Fetched git://github.com/tobyink/path-iterator-rule.git master -> review/tobyink-master

Then I can work with the local review/tobyink-master branch to inspect it, rebase it, cherry-pick it, amend it, run tests or whatever.

I'm glad the pull requests and related discussions are on GitHub, but I like working with them locally. Now I can.

This entry was posted in git, perl programming and tagged , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

5 Comments

  1. Posted March 27, 2013 at 11:01 pm | Permalink
  2. Posted March 28, 2013 at 8:53 am | Permalink

    You might find the tool App::GitHubPullRequest I wrote handy. It's even
    shorter and more to the point than your script. It's on CPAN. It was
    made specifically for people that don't like to interact with the GitHub
    pull request web interface and prefer the shell.

    Your workflow above would be something like this:
    git pr login # only required once per user (not per repo)
    git pr # to find the pull request you want to work on
    git pr show X # show pull request + comments
    git pr checkout X # create a local branch named pr/X
    ...do your review work...
    git pr comment X # say what you need to say
    git pr close X # be done with it
    git branch -d pr/X

    • Posted March 28, 2013 at 8:56 am | Permalink

      Cool. I'll check it out. I don't really like working numerically, though, and one feature of my pull listers is that I can say "--all" and get an overview of all my pulls across all my repos in one shot.

      Still, you've got some good command line workflow there.

    • Posted April 1, 2013 at 2:05 pm | Permalink

      App::GitHubPullRequest looks pretty neat. On a purely OCD level, I would love to see its functionality merged with App-gh (actually, it's already there, but not in working order) so that I end up having to install less modules. Would you be ready to rally forces with Cornelius to make that happen?

  3. Posted April 2, 2013 at 8:21 pm | Permalink

    If you've not tried it, hub is quite a useful tool for command-line integration with github: https://github.com/defunkt/hub

    If you alias it to 'git' it extends git with some syntax sugar to make it work with github more easily, some useful ones:

    "git apply " will apply the pull request to your local repo without merging or commiting.

    "git pull-request" will create a pull request for you from your current branch.

    Might not suit your workflow, but worth a look anyway.

© 2009-2014 David Golden All Rights Reserved