Commit 998deaf3 authored by hinoka@google.com's avatar hinoka@google.com

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
parent 805133df
...@@ -162,7 +162,7 @@ def main(): ...@@ -162,7 +162,7 @@ def main():
scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
elif scm_type == 'git': elif scm_type == 'git':
scm_obj = checkout.GitCheckout(full_dir, None, None, None, None, scm_obj = checkout.GitCheckout(full_dir, None, None, None, None,
base_ref=options.base_ref) base_ref=options.base_ref,)
elif scm_type == None: elif scm_type == None:
scm_obj = checkout.RawCheckout(full_dir, None, None) scm_obj = checkout.RawCheckout(full_dir, None, None)
else: else:
...@@ -179,7 +179,10 @@ def main(): ...@@ -179,7 +179,10 @@ def main():
print('\nApplying the patch.') print('\nApplying the patch.')
try: try:
scm_obj.apply_patch(patchset, verbose=True) scm_obj.apply_patch(
patchset, verbose=True,
email=properties.get('owner_email', 'chrome-bot@chromium.org'),
name=properties.get('owner', 'chrome-bot'))
except checkout.PatchApplicationFailed, e: except checkout.PatchApplicationFailed, e:
print(str(e)) print(str(e))
print('CWD=%s' % os.getcwd()) print('CWD=%s' % os.getcwd())
......
...@@ -131,7 +131,8 @@ class CheckoutBase(object): ...@@ -131,7 +131,8 @@ class CheckoutBase(object):
""" """
raise NotImplementedError() 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. """Applies a patch and returns the list of modified files.
This function should throw patch.UnsupportedPatchFormat or This function should throw patch.UnsupportedPatchFormat or
...@@ -165,7 +166,8 @@ class RawCheckout(CheckoutBase): ...@@ -165,7 +166,8 @@ class RawCheckout(CheckoutBase):
"""Stubbed out.""" """Stubbed out."""
pass 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.""" """Ignores svn properties."""
post_processors = post_processors or self.post_processors or [] post_processors = post_processors or self.post_processors or []
for p in patches: for p in patches:
...@@ -349,7 +351,8 @@ class SvnCheckout(CheckoutBase, SvnMixIn): ...@@ -349,7 +351,8 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
(self.project_name, self.project_path)) (self.project_name, self.project_path))
return self._revert(revision) 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 [] post_processors = post_processors or self.post_processors or []
for p in patches: for p in patches:
stdout = [] stdout = []
...@@ -628,7 +631,8 @@ class GitCheckout(CheckoutBase): ...@@ -628,7 +631,8 @@ class GitCheckout(CheckoutBase):
"""Gets the current revision (in unicode) from the local branch.""" """Gets the current revision (in unicode) from the local branch."""
return unicode(self._check_output_git(['rev-parse', 'HEAD']).strip()) 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. """Applies a patch on 'working_branch' and switches to it.
Also commits the changes on the local branch. Also commits the changes on the local branch.
...@@ -708,6 +712,9 @@ class GitCheckout(CheckoutBase): ...@@ -708,6 +712,9 @@ class GitCheckout(CheckoutBase):
# Once all the patches are processed and added to the index, commit the # Once all the patches are processed and added to the index, commit the
# index. # index.
cmd = ['commit', '-m', 'Committed patch'] cmd = ['commit', '-m', 'Committed patch']
if name and email:
author = '%s <%s>' % (name, email)
cmd.extend(['--author', author])
if verbose: if verbose:
cmd.append('--verbose') cmd.append('--verbose')
self._check_call_git(cmd) self._check_call_git(cmd)
...@@ -818,7 +825,8 @@ class ReadOnlyCheckout(object): ...@@ -818,7 +825,8 @@ class ReadOnlyCheckout(object):
def get_settings(self, key): def get_settings(self, key):
return self.checkout.get_settings(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( return self.checkout.apply_patch(
patches, post_processors or self.post_processors, verbose) patches, post_processors or self.post_processors, verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment