From c7e84d041306082117c5760c10bf19891a35e88e Mon Sep 17 00:00:00 2001 From: Aaron Gable Date: Thu, 27 Apr 2017 14:42:43 -0700 Subject: [PATCH] git-drover: TBR appropriate reviewers When uploading to either Rietveld or Gerrit, this will cause git-cl to add the appropriate reviewers to the cherry-pick review, so they're aware the change is being copied to the release branch. When uploading to Gerrit, this will also cause git-cl to set the Code-Review+1 bit, allowing the CL to be landed R=tandrii@chromium.org Bug: 714720 Change-Id: Ie04e2657a91e4345796ac2200c0115fb18e460a1 Reviewed-on: https://chromium-review.googlesource.com/486961 Commit-Queue: Aaron Gable Reviewed-by: Andrii Shyshkalov --- git_drover.py | 11 ++++++++++- tests/git_drover_test.py | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/git_drover.py b/git_drover.py index f477566aa..f5313fc51 100755 --- a/git_drover.py +++ b/git_drover.py @@ -9,6 +9,7 @@ import cPickle import functools import logging import os +import re import shutil import subprocess import sys @@ -274,7 +275,9 @@ class _Drover(object): return True self._run_git_command(['reset', '--hard']) - self._run_git_command(['cl', 'upload'], + + author = self._run_git_command(['log', '-1', '--format=%ae']).strip() + self._run_git_command(['cl', 'upload', '--tbrs', author], error_message='Upload failed', interactive=True) @@ -294,6 +297,9 @@ class _Drover(object): interaction. If false, the command will be provided with no input and the output is captured. + Returns: + stdout as a string, or stdout interleaved with stderr if self._verbose + Raises: Error: The command failed to complete successfully. """ @@ -321,6 +327,9 @@ class _Drover(object): args: A list of strings containing the args to pass to git. stdin: A string to provide on stdin. + Returns: + stdout as a string, or stdout interleaved with stderr if self._verbose + Raises: Error: The command failed to complete successfully. """ diff --git a/tests/git_drover_test.py b/tests/git_drover_test.py index ea38df600..6c86dae93 100755 --- a/tests/git_drover_test.py +++ b/tests/git_drover_test.py @@ -42,6 +42,7 @@ class GitDroverTest(auto_stub.TestCase): self._commands = [] self._input = [] self._fail_on_command = None + self._reviewers = '' self.REPO_CHECK_COMMANDS = [ (['git', '--help'], self._parent_repo), @@ -61,7 +62,9 @@ class GitDroverTest(auto_stub.TestCase): ] self.UPLOAD_COMMANDS = [ (['git', 'reset', '--hard'], self._target_repo), - (['git', 'cl', 'upload'], self._target_repo), + (['git', 'log', '-1', '--format=%ae'], self._target_repo), + (['git', 'cl', 'upload', '--tbrs', 'author@domain.org'], + self._target_repo), ] self.LAND_COMMAND = [ (['git', 'cl', 'land', '--bypass-hooks'], self._target_repo), @@ -113,6 +116,8 @@ class GitDroverTest(auto_stub.TestCase): return os.path.join(self._parent_repo, '.git') if args == ['git', 'status', '--porcelain']: return ' D foo\nUU baz\n D bar\n' + if args == ['git', 'log', '-1', '--format=%ae']: + return 'author@domain.org' return '' def _Popen(self, args, shell=False, cwd=None, stdin=None, stdout=None, @@ -293,7 +298,7 @@ class GitDroverTest(auto_stub.TestCase): def testFailOnUpload(self): self._input = ['y'] - self._fail_on_command = 12 + self._fail_on_command = 13 self.assertRaises(git_drover.Error, git_drover.cherry_pick_change, 'branch', 'cl', self._parent_repo, False) self.assertEqual(self.REPO_CHECK_COMMANDS + self.LOCAL_REPO_COMMANDS +