Apply patch for submodules when patch needed
For some web apps, we just submodule from external repo,
and our changes sometimes hard to be merged on time, so patch is needed.

Patch file rules:
  1. Patch can be generated by "git format-patch [compared branch name]"
  2. Needed patch files should be located under [WebApp] folder
  3. [IMPORTANT] Patch name should be ordered by alphabetical,
     and will be patched orderly by patch script. (eg. 0001-xxx.patch 0002-yyy.patch)

Apply patch scenario:
  1. Check whether it's a git submodule, otherwise, skip below scenario
  2. Get sorted patch file list (Patches need to be orderly patched)
  3. Check whether patch files under WebApp folder, if none, skip below scenario
  4. Checkout the submodule to 'master' branch
  5. Remove 'auto_patch' branch which was created during previous build
  6. Create a new 'auto_patch' branch
  7. Apply all the patches
  8. Checkout to 'master' branch
'auto_patch' branch will be remained after build for further review.

BUG=#16
Merge pull request #19 from kurli/git_am

Apply patch for submodules when patch needed