Git::Release
============

Git::Release provides many useful features 
to reduce your release process efforts.

it defines many tasks for release process and 
which are generalized, easy to use.

# The Release Process

## The main branches

* master
* develop

### Master Branch

The master branch at origin should be familiar to every Git user. Parallel to
the master branch.

We consider origin/master to be the main branch where the source code of HEAD
always reflects a production-ready state.

### Develop Branch

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.

### Feature Branch

A feature branch may branch off from `develop` branch,

If a feature branch is finished, the branch can merge back to develop.

Or it should merge back to a release branch if the feature branch is schuduled to be released. 
and the branch should be renamed with ready/ prefix, which means this branch is ready to be released.

By this, you can easily distinguish what branch is going to be released, what
branch should be waiting the next release.

To create a feature branch from current branch:

    $ git feature [feature name]

To create a feature branch from a branch:

    $ git feature [feature name] [your branch]

This will create a feature branch with prefix `feature/`, you can configure the prefix in your `.gitconfig` file.

A branch named like `feature/ajax` will be created.


To show the document of a branch:

    $ git branch-doc


### Hotfix Branch

May branch off from `master`,

Must merge back to `develop` and `master`.


To create a hotfix branch from master:

    $ git hotfix [hotfix name]

This is not recommended, but you can still create a hotfix branch from a specified branch, 
if your production branch is not named master,

    $ git hotfix [hotfix name] your_branch



### Release Ready Branch

When your feature branch or hotfix branch are ready to go, move into ready/ directory,
and the branch will be merged into current release branch for testing.

To move current branch to ready/:

    $ git ready

To move specified branch to ready/:

    $ git ready [branch name]

To setup specified branch to ready, and merge into specified branch (master or develop)

    $ git ready [branch name] --merge [target branches]

For example, to setup hotfix-3011 branch to ready, and merge into master, develop branches:

    $ git ready hotfix-3011 --merge master,develop


Steps are followed below:

* Trigger unit tests, selenium tests, continue to next step if it passed.
* Move local branch to ready/
* Prune remote branches.
* Merge into current release branch.

### Release Branch

A release branch may branch off from `develop`, 
and must merge back into: `develop` & `master`.

Branch naming convention: `release-*`


To create a release branch (should be branched from develop)

    $ git release new [version name]

Once your release branch is ready, you can run release.

    $ git release

The git release steps are followed below,

* Move current ready/ branches into released.
* Merge current release branch into master.
* Delete current release branch.
* Tag a release version on master.
* Rebase master branch onto `develop` branch.


### Site Branch

Each different site depends on a different released framework version,
So a site branch is branched off from a released framework version.

Custom Features might be developed on it, some of them can be merged back into
the next release branch.

# Helper Scripts

    git-ready
    git-ready-to-released
    git-rm-released


# Setup

To install Git::Release process flow helper scripts.

    git release-init



# Configuration

to customzie your git-release config, edit your .gitconfig:
    
    [release]
        develop-branch = development
        production-branch = master
        production-branch = production
        release-branch-prefix = release/
        feature-branch-prefix = feature/
        hotfix-branch-prefix  = hotfix/
        site-branch-prefix    = 

# Reference

http://nvie.com/posts/a-successful-git-branching-model/

http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html


# Todo

* ticket integration.
* config integration.

(Comments are welcome)
