-
Notifications
You must be signed in to change notification settings - Fork 533
Support the "pull requests of feature branches with a protected develop branch" workflow #358
Description
I'd like to use the flow model of feature branches and separate stable/development branches, but I heavily use the model where branches are merged through GitHub pull requests and the main branch is protected so no-one can push to it without a PR that can be reviewed and must go through CI first. I've even locked it so even as the repository owner I cannot accidentally push something broken and must follow the same process any other contributor must go through. I believe this is also a good model that fits in with gitflow because it allows you to work on multiple feature branches and have them accepted separately. If you make a pull request from develop instead of from feature/foo then you cannot merge feature/bar into your develop branch until the repository owner has merged your develop branch with feature/foo in it. Otherwise the maintainer will have to simultaneously accept both foo and bar at the same time.
I understand there have been other issues with different suggestions (#208 #327 #330) but I don't quite see why this model can't just be supported by gitflow, it seems to fit in fairly well with gitflow and even enhance gitflow.
Would it be possible to have a flag we can enable for a pull request mode of feature branches.
When the flag is enabled git flow feature finish behaves differently.
If the feature branch has not been pushed to any remote, it behaves as normal (to allow package maintainers to work on local features).
If the feature branch has been published to a remote and has not been merged, instead of merging and deleting the branch the command bails out and warns the user that they should create a pull request for their feature branch. A -f/--force option can be used if the user still needs the normal behaviour.
If the feature branch has been published to a remote and the latest commit in the feature branch has been merged into develop, then the command switches to that commit develop (instead of merging to it) and deletes the feature branch and remote feature branch.
In this way git flow feature finish remains safe and remains a useful portion of the git flow workflow:
git flow feature start foo- Start a feature branch as normalgit flow feature publish- Publish a remote version of your feature branch to share with the repository owner- Start a pull request
- The package maintainer merges your feature branch into
develop git flow feature finish- Checks to make sure that your feature has been merged intodevelopas it would have done on its own before. If something is wrong it warns you, so you don't accidentally delete your feature branch before it accepted. And if it has been merged and is safe to do so, deletes the feature branch and published remote to "finish" the branch by cleaning it up.