|
|
> This needs updating to a slightly different git branching model based on [this](http://nvie.com/posts/a-successful-git-branching-model/).
|
|
|
We essentially follow [this git branching model](http://nvie.com/posts/a-successful-git-branching-model/). Developers are expected to use the full model locally, however, the main MathJax repository should only contain develop, master and release branches, i.e., teams should work together and make pull requests after merging the finished work into develop.
|
|
|
|
|
|
We are using git via GitHub as the main source control mechanism for MathJax. At the same time, we will also be releasing MathJax 1.1 near the end of the year, and we already have minor point releases to the MathJax 1.0 release to manage. Finally, we would like to begin hosting MathJax through a CDN, which has high requirements both for timely bug fixes and stability.
|
|
|
|
|
|
Consequently, we need to begin following a more systematic and controlled plan for source control. This document lays out that plan.
|
|
|
We are using git via GitHub as the main source control mechanism for MathJax; the SVN repository at Sourceforge has been discontinued in 2011.
|
|
|
|
|
|
### Requirements
|
|
|
|
|
|
Looking at all uses outlined above that our source control plan has to accommodate, we obtain these requirements:
|
|
|
|
|
|
* We need a "master" branch for active development. While we will attempt to keep the master stable, it will change rapidly as development proceeds. It follows no users should use the master branch for production purposes.
|
|
|
* We need stable "release" branches that are always guaranteed to point to a stable, tested version. These are branches that users can use for production.
|
|
|
* We need a develop branch for active development. While we will attempt to keep the develop stable, it will change rapidly as development proceeds. It follows no users should use the develop branch for production purposes.
|
|
|
* We need stable release branches that are always guaranteed to point to a stable, tested version. These are branches that users can use for production.
|
|
|
* We need to be able to make Hotfixes for bugs to releases and deploy them as "point releases" between major releases.
|
|
|
* We need to be able to use source control to share "candidate release" files for testing before releasing them as major or hotfix releases.
|
|
|
* We need to periodically package release snapshots for distribution (e.g. zip files) and be able to restore via source control to the code state corresponding to any given snapshot.
|
... | ... | @@ -20,47 +16,330 @@ Note that the requirements basically identify two roles for source control. |
|
|
|
|
|
Many projects use only a single master code line and don't maintain release branches. The reason we want to do this is that we anticipate users who will need hotfixes (e.g. for bugs introduced by browser updates) but that won't want to update to the master development line. For example, if a user has customizations that would need updates due to changes in the master line unrelated to the hotfix, they may not have time and resources to do that work just to get the hotfix.
|
|
|
|
|
|
For a case study of another organization with similar requirements and their usage of Git to support them, see
|
|
|
http://dev.innovationfactory.nl/2010/06/09/development-and-release-strategy-with-git/
|
|
|
### @Nvie's model
|
|
|
|
|
|
The following is quoted from http://nvie.com/posts/a-successful-git-branching-model/, Published: January 05, 2010
|
|
|
|
|
|
#### At a glance
|
|
|
From http://nvie.com/
|
|
|
|
|
|
![](http://nvie.com/img/2009/12/Screen-shot-2009-12-24-at-11.32.03.png)
|
|
|
|
|
|
|
|
|
#### Decentralized but centralized
|
|
|
|
|
|
The repository setup that we use and that works well with this branching
|
|
|
model, is that with a central “truth” repo, https://github.com/mathjax/MathJax/. Note that this repo is only
|
|
|
*considered* to be the central one (since Git is a DVCS, there is no
|
|
|
such thing as a central repo at a technical level). We will refer to
|
|
|
this repo as `origin`, since this name is familiar to all Git users.
|
|
|
|
|
|
![](http://nvie.com/img/2010/01/centr-decentr.png)
|
|
|
|
|
|
Each developer pulls and pushes to origin. But besides the centralized
|
|
|
push-pull relationships, each developer may also pull changes from other
|
|
|
peers to form sub teams. For example, this might be useful to work
|
|
|
together with two or more developers on a big new feature, before
|
|
|
pushing the work in progress to `origin` prematurely. In the figure
|
|
|
above, there are subteams of Alice and Bob, Alice and David, and Clair
|
|
|
and David.
|
|
|
|
|
|
Technically, this means nothing more than that Alice has defined a Git
|
|
|
remote, named `bob`, pointing to Bob’s repository, and vice versa.
|
|
|
|
|
|
#### The main branches
|
|
|
|
|
|
|
|
|
![](http://nvie.com/img/2009/12/bm002.png)
|
|
|
|
|
|
At the core, the development model is greatly inspired by existing
|
|
|
models out there. The central repo holds two main branches with an
|
|
|
infinite lifetime:
|
|
|
|
|
|
- `master`
|
|
|
- `develop`
|
|
|
|
|
|
The `master` branch at `origin` should be familiar to every Git user.
|
|
|
Parallel to the `master` branch, another branch exists called `develop`.
|
|
|
|
|
|
We consider `origin/master` to be the main branch where the source code
|
|
|
of `HEAD` always reflects a *production-ready* state.
|
|
|
|
|
|
We consider `origin/develop` to be the main branch where the source code
|
|
|
of `HEAD` always reflects a state with the latest delivered development
|
|
|
changes for the next release. Some would call this the “integration
|
|
|
branch”. This is where any automatic nightly builds are built from.
|
|
|
|
|
|
When the source code in the `develop` branch reaches a stable point and
|
|
|
is ready to be released, all of the changes should be merged back into
|
|
|
`master` somehow and then tagged with a release number. How this is done
|
|
|
in detail will be discussed further on.
|
|
|
|
|
|
Therefore, each time when changes are merged back into `master`, this is
|
|
|
a new production release *by definition*. We tend to be very strict at
|
|
|
this, so that theoretically, we could use a Git hook script to
|
|
|
automatically build and roll-out our software to our production servers
|
|
|
everytime there was a commit on `master`.
|
|
|
|
|
|
####### Supporting branches
|
|
|
|
|
|
|
|
|
Next to the main branches `master` and `develop`, our development model
|
|
|
uses a variety of supporting branches to aid parallel development
|
|
|
between team members, ease tracking of features, prepare for production
|
|
|
releases and to assist in quickly fixing live production problems.
|
|
|
Unlike the main branches, these branches always have a limited life
|
|
|
time, since they will be removed eventually.
|
|
|
|
|
|
The different types of branches we may use are:
|
|
|
|
|
|
- Feature branches
|
|
|
- Release branches
|
|
|
- Hotfix branches
|
|
|
|
|
|
Each of these branches have a specific purpose and are bound to strict
|
|
|
rules as to which branches may be their originating branch and which
|
|
|
branches must be their merge targets. We will walk through them in a
|
|
|
minute.
|
|
|
|
|
|
By no means are these branches “special” from a technical perspective.
|
|
|
The branch types are categorized by how we *use* them. They are of
|
|
|
course plain old Git branches.
|
|
|
|
|
|
####### Feature branches
|
|
|
|
|
|
![](http://nvie.com/img/2009/12/fb.png)
|
|
|
|
|
|
May branch off from: `develop`\
|
|
|
Must merge back into: `develop`\
|
|
|
Branch naming convention: anything except `master`, `develop`,
|
|
|
`release-*`, or `hotfix-*`
|
|
|
|
|
|
Feature branches (or sometimes called topic branches) are used to
|
|
|
develop new features for the upcoming or a distant future release. When
|
|
|
starting development of a feature, the target release in which this
|
|
|
feature will be incorporated may well be unknown at that point. The
|
|
|
essence of a feature branch is that it exists as long as the feature is
|
|
|
in development, but will eventually be merged back into `develop` (to
|
|
|
definitely add the new feature to the upcoming release) or discarded (in
|
|
|
case of a disappointing experiment).
|
|
|
|
|
|
Feature branches typically exist in developer repos only, not in
|
|
|
`origin`.
|
|
|
|
|
|
####### Creating a feature branch
|
|
|
|
|
|
When starting work on a new feature, branch off from the `develop`
|
|
|
branch.
|
|
|
|
|
|
$ git checkout -b myfeature develop
|
|
|
Switched to a new branch "myfeature"
|
|
|
|
|
|
#### Incorporating a finished feature on develop
|
|
|
|
|
|
Finished features may be merged into the `develop` branch definitely add
|
|
|
them to the upcoming release:
|
|
|
|
|
|
$ git checkout develop
|
|
|
Switched to branch 'develop'
|
|
|
$ git merge --no-ff myfeature
|
|
|
Updating ea1b82a..05e9557
|
|
|
(Summary of changes)
|
|
|
$ git branch -d myfeature
|
|
|
Deleted branch myfeature (was 05e9557).
|
|
|
$ git push origin develop
|
|
|
|
|
|
The `--no-ff` flag causes the merge to always create a new commit
|
|
|
object, even if the merge could be performed with a fast-forward. This
|
|
|
avoids losing information about the historical existence of a feature
|
|
|
branch and groups together all commits that together added the feature.
|
|
|
Compare:
|
|
|
|
|
|
![](http://nvie.com//img/2010/01/merge-without-ff.png)
|
|
|
|
|
|
In the latter case, it is impossible to see from the Git history which
|
|
|
of the commit objects together have implemented a feature—you would have
|
|
|
to manually read all the log messages. Reverting a whole feature (i.e. a
|
|
|
group of commits), is a true headache in the latter situation, whereas
|
|
|
it is easily done if the `--no-ff` flag was used.
|
|
|
|
|
|
####### Release branches
|
|
|
|
|
|
May branch off from: `develop`\
|
|
|
Must merge back into: `develop` and `master`\
|
|
|
Branch naming convention: `release-*`
|
|
|
|
|
|
Release branches support preparation of a new production release. They
|
|
|
allow for last-minute dotting of i’s and crossing t’s. Furthermore, they
|
|
|
allow for minor bug fixes and preparing meta-data for a release (version
|
|
|
number, build dates, etc.). By doing all of this work on a release
|
|
|
branch, the `develop` branch is cleared to receive features for the next
|
|
|
big release.
|
|
|
|
|
|
The key moment to branch off a new release branch from `develop` is when
|
|
|
develop (almost) reflects the desired state of the new release. At least
|
|
|
all features that are targeted for the release-to-be-built must be
|
|
|
merged in to `develop` at this point in time. All features targeted at
|
|
|
future releases may not—they must wait until after the release branch is
|
|
|
branched off.
|
|
|
|
|
|
It is exactly at the start of a release branch that the upcoming release
|
|
|
gets assigned a version number—not any earlier. Up until that moment,
|
|
|
the `develop` branch reflected changes for the “next release”, but it is
|
|
|
unclear whether that “next release” will eventually become 0.3 or 1.0,
|
|
|
until the release branch is started. That decision is made on the start
|
|
|
of the release branch and is carried out by the project’s rules on
|
|
|
version number bumping.
|
|
|
|
|
|
######## Creating a release branch
|
|
|
|
|
|
Release branches are created from the `develop` branch. For example, say
|
|
|
version 1.1.5 is the current production release and we have a big
|
|
|
release coming up. The state of `develop` is ready for the “next
|
|
|
release” and we have decided that this will become version 1.2 (rather
|
|
|
than 1.1.6 or 2.0). So we branch off and give the release branch a name
|
|
|
reflecting the new version number:
|
|
|
|
|
|
$ git checkout -b release-1.2 develop
|
|
|
Switched to a new branch "release-1.2"
|
|
|
$ ./bump-version.sh 1.2
|
|
|
Files modified successfully, version bumped to 1.2.
|
|
|
$ git commit -a -m "Bumped version number to 1.2"
|
|
|
[release-1.2 74d9424] Bumped version number to 1.2
|
|
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
|
|
|
|
|
After creating a new branch and switching to it, we bump the version
|
|
|
number. Here, `bump-version.sh` is a fictional shell script that changes
|
|
|
some files in the working copy to reflect the new version. (This can of
|
|
|
course be a manual change—the point being that *some* files change.)
|
|
|
Then, the bumped version number is committed.
|
|
|
|
|
|
This new branch may exist there for a while, until the release may be
|
|
|
rolled out definitely. During that time, bug fixes may be applied in
|
|
|
this branch (rather than on the `develop` branch). Adding large new
|
|
|
features here is strictly prohibited. They must be merged into
|
|
|
`develop`, and therefore, wait for the next big release.
|
|
|
|
|
|
######## Finishing a release branch
|
|
|
|
|
|
When the state of the release branch is ready to become a real release,
|
|
|
some actions need to be carried out. First, the release branch is merged
|
|
|
into `master` (since every commit on `master` is a new release *by
|
|
|
definition*, remember). Next, that commit on `master` must be tagged for
|
|
|
easy future reference to this historical version. Finally, the changes
|
|
|
made on the release branch need to be merged back into `develop`, so
|
|
|
that future releases also contain these bug fixes.
|
|
|
|
|
|
The first two steps in Git:
|
|
|
|
|
|
$ git checkout master
|
|
|
Switched to branch 'master'
|
|
|
$ git merge --no-ff release-1.2
|
|
|
Merge made by recursive.
|
|
|
(Summary of changes)
|
|
|
$ git tag -a 1.2
|
|
|
|
|
|
The release is now done, and tagged for future reference.\
|
|
|
**Edit:** You might as well want to use the `-s` or `-u <key>` flags to
|
|
|
sign your tag cryptographically.
|
|
|
|
|
|
To keep the changes made in the release branch, we need to merge those
|
|
|
back into `develop`, though. In Git:
|
|
|
|
|
|
$ git checkout develop
|
|
|
Switched to branch 'develop'
|
|
|
$ git merge --no-ff release-1.2
|
|
|
Merge made by recursive.
|
|
|
(Summary of changes)
|
|
|
|
|
|
This step may well lead to a merge conflict (probably even, since we
|
|
|
have changed the version number). If so, fix it and commit.
|
|
|
|
|
|
Now we are really done and the release branch may be removed, since we
|
|
|
don’t need it anymore:
|
|
|
|
|
|
$ git branch -d release-1.2
|
|
|
Deleted branch release-1.2 (was ff452fe).
|
|
|
|
|
|
####### Hotfix branches
|
|
|
|
|
|
![](http://nvie.com/img/2010/01/hotfix-branches1.png)
|
|
|
|
|
|
May branch off from: `master`\
|
|
|
Must merge back into: `develop` and `master`\
|
|
|
Branch naming convention: `hotfix-*`
|
|
|
|
|
|
Hotfix branches are very much like release branches in that they are
|
|
|
also meant to prepare for a new production release, albeit unplanned.
|
|
|
They arise from the necessity to act immediately upon an undesired state
|
|
|
of a live production version. When a critical bug in a production
|
|
|
version must be resolved immediately, a hotfix branch may be branched
|
|
|
off from the corresponding tag on the master branch that marks the
|
|
|
production version.
|
|
|
|
|
|
The essence is that work of team members (on the `develop` branch) can
|
|
|
continue, while another person is preparing a quick production fix.
|
|
|
|
|
|
######## Creating the hotfix branch
|
|
|
|
|
|
### Source Control Lines and Usage
|
|
|
Hotfix branches are created from the `master` branch. For example, say
|
|
|
version 1.2 is the current production release running live and causing
|
|
|
troubles due to a severe bug. But changes on `develop` are yet unstable.
|
|
|
We may then branch off a hotfix branch and start fixing the problem:
|
|
|
|
|
|
The Model
|
|
|
$ git checkout -b hotfix-1.2.1 master
|
|
|
Switched to a new branch "hotfix-1.2.1"
|
|
|
$ ./bump-version.sh 1.2.1
|
|
|
Files modified successfully, version bumped to 1.2.1.
|
|
|
$ git commit -a -m "Bumped version number to 1.2.1"
|
|
|
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
|
|
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
|
|
|
|
|
Since branching and merging are lightweight and fundamental operations in Git, we will take advantage of that. The basic model is:
|
|
|
Don’t forget to bump the version number after branching off!
|
|
|
|
|
|
* In the MathJax repository at GitHub, there is
|
|
|
a single master line for development
|
|
|
multiple release branches, primarily for code distribution and archival purposes
|
|
|
* The MathJax master line represents the most recent stable development version
|
|
|
* Developers work in personnel forks of the MathJax repository, using feature branches as necessary to encapsulate work
|
|
|
* When a block of work has been reviewed and tested, it is merged into the master line at GitHub. In this way, we attempt to keep the master stable.
|
|
|
* The MathJax release lines represent the most recent stable production versions
|
|
|
* The only submissions in a release line is the initial version, corresponding to a packaged snapshot, and any subsequent hotfixes.
|
|
|
* When a hotfix is needed, a developer would prepare a branch of of the release line (in his or her fork of the repository, and complete the coding. QA would then test that branch. When the branch passes testing, it would be merged to the release branch in the MathJax repository at GitHub.
|
|
|
* Independently, a separate branch of MathJax/master would be prepared and the fix merged with it in the developer's repository. That branch would also be tested, and when it passed, the hotfix would be merged to MathJax/master on GitHub as well.
|
|
|
* For packaging snapshots, we will tag points on our release branches, and package the distribution ourselves. We may be able to exclusively rely on GitHubs file download manager, but in the short term, we will also continue to host downloads at SourceForge.
|
|
|
Then, fix the bug and commit the fix in one or more separate commits.
|
|
|
|
|
|
$ git commit -m "Fixed severe production problem"
|
|
|
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
|
|
|
5 files changed, 32 insertions(+), 17 deletions(-)
|
|
|
|
|
|
### Testing
|
|
|
**Finishing a hotfix branch**
|
|
|
|
|
|
Note that a key concept for both the MathJax/master and MathJax/release code lines is that only tested code will be merged in. The model for testing is that a developer implements a work item in a feature branch or branches created however the developer deems appropriate. When work is complete, however, the developer then prepares a testing branch in his or her fork of the MathJax repository.
|
|
|
When finished, the bugfix needs to be merged back into `master`, but
|
|
|
also needs to be merged back into `develop`, in order to safeguard that
|
|
|
the bugfix is included in the next release as well. This is completely
|
|
|
similar to how release branches are finished.
|
|
|
|
|
|
The testing branch may be the development branch, but the key property is that any changes in the line into which it is to be merged (typically MathJax/master) that have occured during implementation are merged into the testing branch and all conflicts resolved. Thus the testing branch represents the state that master will be in after the feature is merged into it.
|
|
|
First, update `master` and tag the release.
|
|
|
|
|
|
Once that testing branch is ready, the feature is marked as ready for review, and is tested. According to our [[Development Process]], the review and testing is currently the responsibility of either Davide or Sean. Provided it passes testing, it is then to be merged. For now, Davide will be responsible for all merges into the MathJax master and release lines on GitHub.
|
|
|
$ git checkout master
|
|
|
Switched to branch 'master'
|
|
|
$ git merge --no-ff hotfix-1.2.1
|
|
|
Merge made by recursive.
|
|
|
(Summary of changes)
|
|
|
$ git tag -a 1.2.1
|
|
|
|
|
|
### SVN Mirror
|
|
|
**Edit:** You might as well want to use the `-s` or `-u <key>` flags to
|
|
|
sign your tag cryptographically.
|
|
|
|
|
|
We will mirror our GitHub repository to the old SVN repository on SourceForge. The MathJax/master line should go to the trunk/. Ideally the release lines should be mirrored to the tags/ lines in SVN, but this may not be worth the effort.
|
|
|
Next, include the bugfix in `develop`, too:
|
|
|
|
|
|
We will only do one way mirroring, GitHub -> SourceForge. There should be no further check-ins to the SVN repo.
|
|
|
$ git checkout develop
|
|
|
Switched to branch 'develop'
|
|
|
$ git merge --no-ff hotfix-1.2.1
|
|
|
Merge made by recursive.
|
|
|
(Summary of changes)
|
|
|
|
|
|
### Transitioning our current source code repository.
|
|
|
The one exception to the rule here is that, **when a release branch
|
|
|
currently exists, the hotfix changes need to be merged into that release
|
|
|
branch, instead of `develop`**. Back-merging the bugfix into the release
|
|
|
branch will eventually result in the bugfix being merged into `develop`
|
|
|
too, when the release branch is finished. (If work in `develop`
|
|
|
immediately requires this bugfix and cannot wait for the release branch
|
|
|
to be finished, you may safely merge the bugfix into `develop` now
|
|
|
already as well.)
|
|
|
|
|
|
Currently, in our SVN/trunk and GitHub/master lines are in sync and being mirrored.
|
|
|
Finally, remove the temporary branch:
|
|
|
|
|
|
To move to the master-and-release model proposed above, we should
|
|
|
Branch MathJax/master to create a MathJax/mathjax-1.0.1 release line
|
|
|
Continue with MathJax 1.1 development work in MathJax/master |
|
|
\ No newline at end of file |
|
|
$ git branch -d hotfix-1.2.1
|
|
|
Deleted branch hotfix-1.2.1 (was abbe5d6). |