All Your Pull Request Are Belong to Us



GitHub is a great resource.

You have a problem. It looks like a wheel and smells like a wheel. You’re sure it’s a wheel. Last time you checked, that’s something that’s already been invented. Thus begins your search.

After a bit of digging, you find a blog post about a certain project. It seems to have some critical mass behind it. Or at least, it did, when the post was written.

That was maybe a whole six months ago, and when you go to the project’s GitHub page, you see there are 90 forks, and 37 pull requests waiting. The project’s popular, and still somewhat active, but falling behind a bit when it comes to integrating changes made by outsiders. You notice that at least a few of the pull requests solve issues that are likely to be important to you.

At this point, maybe you think, “Well, maybe one of the forks is more actively maintained.” If the project inactive for long enough, there might be some discussion in an issue on the original repo–but the discussion may not necessarily yield up-to-date information. There might be a way to automate this search, but then again, definitions of “more actively maintained” may vary.

In the end, maybe you decide to stick with the original upstream repo, but really want some of those PRs.

Welcom2 teh forks.  Which of you anarchists is in charge, here?

Here’s where I can help with a tiny bit of semi-automation. You’ll still have to be careful about which pull requests you take, and merge any conflicts that arise. One repo I was using this technique on had two PRs solving the same issue, but in slightly different ways. This is the kind of thing you will have to manage, so I recommend making a list of all the PRs you want to incorporate before you start.

Fork the repo, then check out this gist–it’s meant for bash (particularly line 4), but you could adapt the basic principle to the Windows command line easily enough (or use Cygwin) if needed. The gist of the gist it is that it lets you run, for example, pr 55 to bring the upstream repo’s Pull Request #55 into the local clone of your fork.

I’ve used this technique twice already in as many weeks. I hope you find it as useful as I have!