Pass in "--author 'name <email@somewhere.com>" when doing git patches in apply_issue.py

This is to tackle the issue that slaves don't have global git vars set up.

BUG=339171

Review URL: https://codereview.chromium.org/175543006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@252705 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/checkout.py b/checkout.py
index cc57008..2c9c68a 100644
--- a/checkout.py
+++ b/checkout.py
@@ -131,7 +131,8 @@
     """
     raise NotImplementedError()
 
-  def apply_patch(self, patches, post_processors=None, verbose=False):
+  def apply_patch(self, patches, post_processors=None, verbose=False,
+                  name=None, email=None):
     """Applies a patch and returns the list of modified files.
 
     This function should throw patch.UnsupportedPatchFormat or
@@ -165,7 +166,8 @@
     """Stubbed out."""
     pass
 
-  def apply_patch(self, patches, post_processors=None, verbose=False):
+  def apply_patch(self, patches, post_processors=None, verbose=False,
+                  name=None, email=None):
     """Ignores svn properties."""
     post_processors = post_processors or self.post_processors or []
     for p in patches:
@@ -349,7 +351,8 @@
           (self.project_name, self.project_path))
     return self._revert(revision)
 
-  def apply_patch(self, patches, post_processors=None, verbose=False):
+  def apply_patch(self, patches, post_processors=None, verbose=False,
+                  name=None, email=None):
     post_processors = post_processors or self.post_processors or []
     for p in patches:
       stdout = []
@@ -628,7 +631,8 @@
     """Gets the current revision (in unicode) from the local branch."""
     return unicode(self._check_output_git(['rev-parse', 'HEAD']).strip())
 
-  def apply_patch(self, patches, post_processors=None, verbose=False):
+  def apply_patch(self, patches, post_processors=None, verbose=False, 
+                  name=None, email=None):
     """Applies a patch on 'working_branch' and switches to it.
 
     Also commits the changes on the local branch.
@@ -708,6 +712,9 @@
     # Once all the patches are processed and added to the index, commit the
     # index.
     cmd = ['commit', '-m', 'Committed patch']
+    if name and email:
+      author = '%s <%s>' % (name, email)
+      cmd.extend(['--author', author])
     if verbose:
       cmd.append('--verbose')
     self._check_call_git(cmd)
@@ -818,7 +825,8 @@
   def get_settings(self, key):
     return self.checkout.get_settings(key)
 
-  def apply_patch(self, patches, post_processors=None, verbose=False):
+  def apply_patch(self, patches, post_processors=None, verbose=False,
+                  name=None, email=None):
     return self.checkout.apply_patch(
         patches, post_processors or self.post_processors, verbose)