Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Feature: Maintainer workflow #491
Comments
What is the use-case for this? I'd assumed that just checking out the PR into a new branch would suffice. At least that's the way that desktop does it. |
|
Here are my notes from the initial spike I did last week. It goes into a little more detail on how things might work in the PR list pane. Flow for Maintainer Workflow
Questions
|
If there's already an existing branch that matches the naming pattern that we use, then it's likely the user has already created a branch for the PR and somehow we lost track of it. We need to decide whether to use a different name for the branch or ask the user if they want to use the existing one, or disable the feature entirely and let the user switch branches. But this would only happen if the repo is already set up to do PRs before, so this is on the wrong part of the flow. |
Do you mean "Once merged" here? |
Sync is way too overloaded with meaning to use here, people will assume we're pushing things. "Update" or "Update local branch" or something more clear is probably preferable.
"pr/###-title-of-PR" would be nicer than just the number.
If they make changes and don't commit, we can't do anything to the local branch. If they make changes and commit them, we need to decide whether we want to do a fetch&merge or tell them to do it themselves via the git UI.
We can always tell if a local branch is appropriate by checking if it's tracking a remote branch and whether it matches the remote branch with no local changes. This is where we should probably ask the user if they want to reuse an existing branch.
The local one is always deletable once the PR is merged. Dunno what to do about the remote one, I agree that it's going to be confusing if "Clean up" means different things depending on whether you have permissions to the repo or not. Separate feature idea: "Remote clean up" button that clears all remote branches whose tips are already on master, and "Local clean up" button that prunes all useless local branches whose tips are already on master. |
|
Ugh, I could really use a list of files that go with this PR right so I can quickly jump to them. |
|
With regards to checking out a PR, above it was written "Adds PR remote to your local clone, if not there yet". This may not be necessary as all PRs are available from the With this in mind, the method of checking out a PR may be:
We then need a method of identifying an already checked out PR and updating that checked out PR:
|
It shouldn't need to be set to anything, since it's not going to be pushed.
Probably a good idea to standardize on branch names, definitely. But we can save information on which PRs we checkout, we have local storage for this, so we can match up things so we don't have to guess. We'll definitely need this if/when we let users pick an existing branch for checking out instead of us creating one for them. |
I'm not sure this will always be the case. When I suggested this last week, @niik pointed out that in Desktop once a PR is checked out it's like any other branch, in that a user can make changes to it and push it to origin etc. I thought about it, and indeed that is a feature that I sometimes take advantage of, so I'd imagine it's not a completely unusual scenario. |
|
In that case, being like any other branch, push should only be set when the user actually pushes the branch somewhere, just like any other branch. |
|
Right, but then the fetch and push remotes would be different, which would cause confusion I expect, e.g.
I don't know if this is a scenario we want to support, If we make "sync from upstream* fork" an operation that VS does by locating the PR by name/local storage and merging from *: Downstream? |
So let's see, why would they push to get feedback? If they're going to push the branch manually to their repo, they're probably going to take ownership of the PR. No more changes are expected to come from the contributor and their PR probably gets closed, since it won't get merged. With protected branches, the maintainer still needs a PR, so we'd go through an "importing" process. If the contributor pushes more things that the maintainer wants to pull, they need to do that manually, it's way outside a normal workflow. There's now two diverging branches. If the maintainer wants to push some changes to show the contributor how something is done, the branch is no longer able to be synched with the contributor branch, and the maintainer needs to reset the branch if they want to get contributor changes again. If two maintainers want to collaborate on a branch for the purpose of showing a contributor how to do things, again they have to reset the branch to be able to get contributor changes. This means that if maintainers want to make changes to a pr branch, they are effectively breaking the connection with the contributor branch. If they then want to collaborate, they'll need to set up tracking information accordingly. That means that there may be a |
|
Like I said, I'm not sure this is something we want to support, however, I feel that by having PR branches for forks just being "normal" branches we're likely to avoid some user confusion. If they're special branches with a different fetch and push ref then I suspect we'll have people scratching their heads. To address specific points:
Yes, probably, however things are rarely so clean in real life, and git works so well at merging from different sources that I think we can take advantage of this:
Even though this workflow is messy, it's completely supported by git and handled well through merges. Conflicts can be resolved just like anywhere else. When finally everyone is happy with the results, the local PR branch is merged to master and the PR gets automatically closed when pushed. (* see protected branches comment below)
With protected branches what you say is true, however I suspect that the majority of projects don't have protected branches enabled (are there metrics for this?) so we need to support the more laissez-faire maintainership that I suspect most projects use. Case study: I've only just switched to protected branches for Avalonia: before I was manually checking out PRs locally, making small changes like whitespace fixes then merging them to master myself and pushing to close the PR. Sometimes contributors would also make changes, and an easy "incorporate PR changes here" button would have been well-received. (Aside: I'm actually thinking of returning to this workflow: protected branches are really slowing down development and in reality nobody is even reviewing my PRs)
Yep, this sums up what's going on in my head: if we assume that tldr; my desire comes from not wanting have any "special" branches lying around that work differently: partly because we can't actually control what the user does to these branches, and partly because git handles these scenarios fine anyway. Again, this is just what I'm currently thinking, my thoughts are still a bit nebulous. |
All of these are complicated scenarios that need a careful git UI that can handle them. We don't have that, so we can't really handle them. The branches we create are for our use case. If a user wants to change their tracking manually so they can push to another place, that's out of our control. Ideally, they would create a separate branch for that and merge our readonly branch to it. We don't have any control over the user deciding to push the branch somewhere, and we don't have any control over whether they decide to change the tracking and do local commits or anything. Since we don't have any control over this, we can't automatically merge in changes from the remote pr branch to a local branch if that branch doesn't match the remote head of the pr branch - we don't know if the user understands that that's going to happen, and surprise git merges are the worst. That requires triggering conflict resolution tools, and the user has no clue why it's happening. For an initial release, I think we need to treat these PR branches as readonly. If you want to push it somewhere, that's fine, we can still fast forward it as long as there are no commits. If there are local commits, it's out of our hands. If it turns out it's confusing to have a fetch ref on the branch, we don't add it and instead fetch and fast forward manually. If the branch has local commits, we can't use it and the user can checkout a new branch from the pr, if they want to. |
|
Just to throw more scenarios into the mix, it may be possible to push to the contributor's PR branch if the contributor allows it: https://github.com/blog/2247-improving-collaboration-with-forks I know in Desktop we use special PR refs that are read only. I feel like for code review, that makes sense as means of not conflating collaboration and code review. However, I can see a reviewer wanting to add little fixes to a review and being confused when pushing doesn't work. I'm assuming there's no way to tell Visual Studio that a current ref is "read only" (though I wonder what happens in the GUI if you check out a tag?) One possible simplification is that we assume that most PRs allow collaboration and we check out the PR branch. And if it didn't allow it, we let the push fail and see how that holds up in practice. |


Entry point
A contributor opens a PR
Reviewing a PR
In the PR list, click on "Review PR" to open the PR Review (details) pane
PR Review UI:
Merging and Closing a PR
The PR Review/Details pane has a Merge and a Close button.
The text was updated successfully, but these errors were encountered: