-
Notifications
You must be signed in to change notification settings - Fork 1
Branching Strategy
Karn Kaul edited this page Nov 21, 2019
·
6 revisions
MicroEngine
follows a simplified Git Branching Model at its core, and the Shared Repository Model on GitHub, using Pull Requests.
There are two kinds of branches in use:
-
Persitent
:- Exist throughout the project's lifetime
- Amending/rebasing commits is forbidden: must never rewrite history
- Usually update via Pull Requests from other branches
-
Transient
:- Exist for short durations of time, eventually to be merged into a persistent branch
- Amending/rebasing is permitted on user branches
Note: Rewriting history means amending / rebasing / resetting commits (such that
origin/{branch}
and{branch}
end up with diverged histories).
New changes are organised into user branches and kept up to date with origin/master
throughout their lifetime. Once completed, they are merged (fast-forwarded) into origin/master
via a Pull Request.
-
origin/master
(Persistent
): The default public state of the repository- Must be stable (code builds and runs on all supported environments)
- Never pushed to (except by administrators)
- Used by: everyone
- Shared branches:
origin/shared-<name>
(andorigin/dev
) (Persistent
):-
Must be up-to-date with
master
- Should be stable
- Updates via merges with
master
and user/feature branches - Used by: Collaborators, contributors
-
Must be up-to-date with
- User branches (
Transient
): Individual branches for development / testing / prototyping / etc- Should always be up to update with
master
- Should minimise commit count before merging back into
master
- Rewriting history is encouraged when aiding in the above
- Updates:
master
=>{branch}
can be rebased, but{branch}
=>master
must be fast-forwarded via a PR - Create them via
git branch {username}/{branch-name}
; that will group them into "directories" in GUI clients - Used by: Individual collaborators
- Should always be up to update with
- Feature branches (
Transient
): Individual long-running features, potentially collaborated upon- Must have a corresponding Issue being tracked
- Should always be up to update with
master
- Should avoid rewriting history
- Used by: Individual / multiple collaborators
- Hotfix branches (
Transient
): Urgent fixes that are inteded to be merged intomaster
- Must have a corresponding Issue being tracked
- Must have as few commits as possible
- Must merge back into
master
as soon as possible (via a Pull Request) - Used by: Collaborators
For more information visit this page.
Creating Pull Requests:
-
git checkout master
and ensure working directory is clean - Create a new user branch:
{username}/awesome-feature
- Commit, amend (not the root commit), rebase (on
master
), push (toorigin/{username}/awesome-feature
), etc - When ready:
- Ensure branch is up-to-date with
origin/master
; merge/rebase if not and resolve all conflicts - Ensure user code is warning-free
- Run
Tools/clang-format.sh -r
- Go to GitHub.com and select "New pull request"
- Pick
base:master
andcompare:{username}/awesome-feature
- Add a meaningful description to the PR (include "close #{Issue}" if applicable)
- Select a reviewer and wait for them to review your changes
- If they request changes, make them and push another commit (on the same branch, and don't rewrite history any more!)
- Otherwise click "Merge" on the Pull Request
- Pull the latest in to your local
master
, and fast-forward your branch to the merged commit (and delete the branch if required)
- Ensure branch is up-to-date with
Reviewing Pull Requests (to origin/master
):
- Ensure the target branch is
master
and the compare branch is up-to-date with it - Ensure linked issue (if present) is correct (and add/edit if necessary)
- Ensure all configured status checks pass (
build
,build_release
, etc), if any - Checkout the compare branch (
{username}/awesome-feature
) - Ensure changes conform to standards and respect
.editorconfig
- Ensure the build passes on all environments you have locally configured
- Ensure the executable does not crash under any obvious conditions
- Run
Tools/clang-format.sh -r
and ensure there are no changes - Take a decision:
- If all is good, select "Approve"
- Otherwise add comments for the PR author and select "Request changes"
- Click "Submit Review"