We recently launched support for what we call “Maintainer Workflows.” You’ve got an open source project and you’re receiving pull requests. Suppose you want the contributor to make some changes. You can leave comments in the Pull Request asking them to make whatever adjustments, e.g. adding a Console.Read(); in a Console Application project. But what if they don’t respond in a timely manner or never respond at all? Now within Visual Studio you can pull down those changes, review them, make modifications, commit and push back up to GitHub, all within the GitHub tool window!
(P.S. the Pull Request contributor needs to create the Pull Request by keeping the “allow edits from maintainers” checkbox checked by default. see more at bottom of post).
Continuing from yesterday’s tip, let’s say you’ve reviewed the diff for the PR but you want to make one addition.
1. You can click on the Checkout to <pr/pr-title> link button to checkout the branch.
Clicking on the checkout… link indicates whether the checkout was successful. If not, it’ll tell you to go to Team Explorer – Changes to see what you have uncommited or unstashed.
If you want to verify what state you are in, you can go to Team Explorer – Branches to confirm you’ve checked out a PR branch. Hovering over gives you additional information. You can also view in the VS status bar.
2. Open the solution (if not already opened from Team Explorer – Home – Solutions) and then open the file you wish to modify.
In this example, I want to add a Console.Read() under the Console.WriteLine() that came from the Pull Request.
Don’t forget to save and test your changes! // This is a note for myself 🙂
3. Go to Team Explorer – Changes and make your commit(s) to the branch
4. Push your changes back up to GitHub from the Team Explorer – Sync page
And you should see a success message.
(We’ll cover more about Syncs in VS in a few weeks.)
If you go to GitHub.com to review the Pull Request, you’ll see that there’s been a new commit.
Let’s take a minute to review what’s going on here. Remember a Pull Request is the start of a conversation. The actual code for the Pull Request sits on a branch that can be updated at anytime, hence why I say a pull request is the “start” of a conversation. In the past, this branch would be updatable by the person who created it. Now because of the new feature upstream repository contributors to collaborate on a forked branch, the user saraford-tips was able to make changes directly to the branch associated with the Pull Request from user drofaras.
When user drofaras created the pull request, she (or I) kept the checkbox checked to allow edits from maintainers.
I strongly recommend using one of the existing channels for feedback. Of course, I’ll help anyone who leaves comments. It’s just that if you use one of the existing channels, your feedback and questions go to the entire team; whereas this blog is my nights and weekends project, so it’ll take me a while to respond, but I will respond. Just don’t ask me how small my queue of tips has become! O_O