prose/prose — pull request #614 by benbalter (2013-10-05 19:16:14+00:00)
Title: Actually implement fork and merge workflow

Fixes #584.

Hello from the DC Legal Hackathon!

Giant PITA. There were a couple of things going on, but largely, I suspect this never worked following the move to backbone:

* Tell jQuery not to cache. Following the fork, and push of the branch ref, The `GET` request for branches was coming from cache, resulting in the branch not being in the collection, resulting in the unprocessable entity error.

* When we create the new file model, we need to grab the commit message, otherwise we'll get an error on the GitHub side of things for missing fields. Perhaps we should just clone the initial file and update what we need instead?

* Some references look for branch and collection.branch to exist as top-level attributes on the file model / files collection. Other references look for it as an attribute. While this should really be fixed and coded properly, saving the information in both places when we create the new file model fixes the problem. This is a work around for a whole bunch of undefined errors.

* In different contexts `file.url()` needs to look in different places to find the branch. Add a bit of robustness to increase our changes of finding it.

![preview bcqkpqiinmgf5jth_500](https://f.cloud.github.com/assets/282759/1275311/74b76c44-2df2-11e3-8265-3500243261f5.gif)

In general, the callback spaghetti, especially in the file model when a bug in `file.url()` only surfaces when it is called for the fourth time in a stack of ten ajax callbacks, was a bit tough to debug. For future efforts, it'd be awesome if things like branching could be methods, rather than anonymous functions.

//cc @konklone who bugged me just the right amount to make this pull request happen.