zendframework / maintainers

Contributors and maintainers information for Zend Framework.
BSD 3-Clause "New" or "Revised" License
50 stars 26 forks source link

Alternative merge workflow utilizing editable PR branches #9

Open Xerkus opened 7 years ago

Xerkus commented 7 years ago

Disclaimer: I will use PR 211 from zendframework/zend-mvc as an example.

Alternative merge workflow can be used if contributor decided to keep access for maintainers to PR branch (At this time it is a default and needs to be explicitly unset if contributor does not want to give push access). Look for the line like this on the PR:
Add more commits by pushing to the documentation-typo-fix branch on chukShirley/zend-http.

This is couple months old feature of the Github and it means that PR can be updated with required changes with no effort on the contributor side.
For example changelog entry can be added and pushed to contributor's PR branch, at which point it will be ready for a merge with The Big Green Button. Pushing changes will also trigger another build, which is a nice side effect.

Plain git workflow is rather simple for the case. It might be made even simpler with additional tools like hub or git aliases. PR command line instructions provide us with some useful info that we can copy paste: PR command line instructions Note the https://github.com/asgrim/zend-mvc.git enable-php71-travis-tests part, this is what we are interested in.

For the feature to be merged into develop things are rather straightforward

# Fetch PR branch locally, into feature/221
(master) $ git fetch https://github.com/asgrim/zend-mvc.git enable-php71-travis-tests:feature/221
# Switch to it
(master) $ git checkout feature/221
# Add changelog entry and commit it
(feature/221) $ vim CHANGELOG.md
(feature/221) $ git add CHANGELOG.md && git commit -m "Added CHANGELOG for #221"
# Push additional changes to a contributor's PR branch
(feature/221) $ git push https://github.com/asgrim/zend-mvc.git HEAD:enable-php71-travis-tests
# At this point a new build will be triggered for a PR, once it finished, PR can be merged
# into develop with the Green Button. We are done

Now, lets assume that PR is a hotfix against master:

# Fetch PR branch locally, into hotfix/221
(master) $ git fetch https://github.com/asgrim/zend-mvc.git enable-php71-travis-tests:hotfix/221
# Switch to it
(master) $ git checkout hotfix/221
# Add changelog entry and commit it
(hotfix/221) $ vim CHANGELOG.md
(hotfix/221) $ git add CHANGELOG.md && git commit -m "Added CHANGELOG for #221"
# Push additional changes to a contributor's PR branch
(hotfix/221) $ git push https://github.com/asgrim/zend-mvc.git HEAD:enable-php71-travis-tests
# At this point a new build will be triggered for a PR, once it finished, PR can be merged
# into master with the Green Button
# Once Pr is merged to master with the button, we need to also merge it into develop:
(hotfix/221) $ git checkout develop
(develop) $ git merge --no-ff hotfix/221
# and push develop to the repo
(develop) $ git push zendframework develop

Now you can do cleanup and remove feature/hotfix branches

@weierophinney here are some more details on what i mentioned on irc