| Index: checkout.py
|
| diff --git a/checkout.py b/checkout.py
|
| index a24fe32ca2838df7a596fa110cb5d9ff77d3cc55..17aa373ed750736557136522650c744f8ea8b789 100644
|
| --- a/checkout.py
|
| +++ b/checkout.py
|
| @@ -265,7 +265,16 @@ class GitCheckoutBase(CheckoutBase):
|
| ['checkout', '-b', self.working_branch,
|
| '%s/%s' % (self.remote, self.remote_branch)])
|
| self._check_call_git(['apply', '--index', '-p0'], stdin=patch_data)
|
| - self._check_call_git(['commit', '-m', 'Committed patch'])
|
| + cmd = ['commit', '-m', 'Committed patch', '--quiet']
|
| + self._check_call_git(cmd)
|
| + commit_user = getattr(self, 'commit_user', None)
|
| + if commit_user:
|
| + try:
|
| + # Try to patch the author with commit_user since it may differ.
|
| + self._check_call_git(cmd + ['--author=%s' % commit_user])
|
| + except subprocess.CalledProcessError, e:
|
| + if e.returncode != 128:
|
| + raise
|
| return self._check_capture_git(['diff', 'master',
|
| '--name-only']).splitlines(False)
|
| except subprocess.CalledProcessError, e:
|
| @@ -274,10 +283,21 @@ class GitCheckoutBase(CheckoutBase):
|
| raise
|
|
|
| def commit(self, commit_message, user):
|
| - """Updates the commit message.
|
| + """Updates the commit message and user if possible.
|
|
|
| - Subclass needs to dcommit or push."""
|
| - self._check_call_git(['commit', '--amend', '-m', commit_message])
|
| + Subclass needs to dcommit or push.
|
| + """
|
| + # Do it in two calls to ease exception management.
|
| + cmd = ['commit', '--amend', '-m', commit_message, '--quiet']
|
| + self._check_call_git(cmd)
|
| + try:
|
| + # git-svn will allow faking the author only if the user already exists in
|
| + # the logs.
|
| + # Provide -m again otherwise git will start a text editor.
|
| + self._check_call_git(cmd + ['--author=%s' % user])
|
| + except subprocess.CalledProcessError, e:
|
| + if e.returncode != 128:
|
| + raise
|
|
|
| def _check_call_git(self, args, **kwargs):
|
| kwargs.setdefault('cwd', self.project_path)
|
| @@ -349,7 +369,7 @@ class GitSvnCheckoutBase(GitCheckoutBase, SvnMixIn):
|
| def commit(self, commit_message, user):
|
| """Commits a patch."""
|
| logging.info('Committing patch for %s' % user)
|
| - # Fix the commit message.
|
| + # Fix the commit message and author.
|
| super(GitSvnCheckoutBase, self).commit(commit_message, user)
|
| # Commit with git svn dcommit, then use svn directly to update the
|
| # committer on the revision.
|
|
|