Commit 76f5fc6c authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Also print comments found in files during presubmit owners suggestion

R=dpranke@chromium.org
BUG=694222

Change-Id: I5676db2283dd43378293bc9bb32f71e0a1225806
Reviewed-on: https://chromium-review.googlesource.com/471609Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
parent fbee1650
......@@ -903,9 +903,20 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
(needed, '\n '.join(sorted(missing_files))))]
if not input_api.is_committing:
suggested_owners = owners_db.reviewers_for(missing_files, owner_email)
finder = input_api.owners_finder(missing_files,
input_api.change.RepositoryRoot(),
owner_email,
fopen=file, os_path=input_api.os_path,
email_postfix='', disable_color=True)
owners_with_comments = []
def RecordComments(text):
owners_with_comments.append(finder.print_indent() + text)
finder.writeln = RecordComments
for owner in suggested_owners:
finder.print_comments(owner)
output_list.append(output_fn('Suggested OWNERS: ' +
'(Use "git-cl owners" to interactively select owners.)\n %s' %
('\n '.join(suggested_owners or []))))
('\n '.join(owners_with_comments))))
return output_list
if input_api.is_committing and not reviewers:
......
......@@ -45,6 +45,7 @@ import fix_encoding
import gclient_utils
import gerrit_util
import owners
import owners_finder
import presubmit_canned_checks
import rietveld
import scm
......@@ -423,6 +424,7 @@ class InputApi(object):
# in order to be able to handle wildcard OWNERS files?
self.owners_db = owners.Database(change.RepositoryRoot(),
fopen=file, os_path=self.os_path)
self.owners_finder = owners_finder.OwnersFinder
self.verbose = verbose
self.Command = CommandData
......
......@@ -23,6 +23,7 @@ sys.path.insert(0, _ROOT)
from testing_support.super_mox import mox, SuperMoxTestBase
import owners
import owners_finder
import subprocess2 as subprocess
import presubmit_support as presubmit
import rietveld
......@@ -163,8 +164,8 @@ class PresubmitUnittest(PresubmitTestsBase):
'auth', 'cPickle', 'cpplint', 'cStringIO',
'contextlib', 'canned_check_filter', 'fix_encoding', 'fnmatch',
'gclient_utils', 'glob', 'inspect', 'json', 'load_files', 'logging',
'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle',
'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
'marshal', 'normpath', 'optparse', 'os', 'owners', 'owners_finder',
'pickle', 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm',
'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest',
'urllib2', 'warn', 'multiprocessing', 'DoGetTryMasters',
'GetTryMastersExecuter', 'itertools', 'urlparse', 'gerrit_util',
......@@ -996,6 +997,7 @@ class InputApiUnittest(PresubmitTestsBase):
'os_path',
'os_stat',
'owners_db',
'owners_finder',
'pickle',
'platform',
'python_executable',
......@@ -2250,6 +2252,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
change.author_email = 'john@example.com'
change.R = ','.join(manually_specified_reviewers)
change.TBR = ''
change.RepositoryRoot = lambda: None
affected_file = self.mox.CreateMock(presubmit.GitAffectedFile)
input_api = self.MockInputApi(change, False)
if gerrit_response:
......@@ -2260,6 +2263,12 @@ class CannedChecksUnittest(PresubmitTestsBase):
fake_db = self.mox.CreateMock(owners.Database)
fake_db.email_regexp = input_api.re.compile(owners.BASIC_EMAIL_REGEXP)
input_api.owners_db = fake_db
fake_finder = self.mox.CreateMock(owners_finder.OwnersFinder)
fake_finder.print_indent = lambda: ''
# pylint: disable=unnecessary-lambda
fake_finder.print_comments = lambda owner: fake_finder.writeln(owner)
input_api.owners_finder = lambda *args, **kwargs: fake_finder
input_api.is_committing = is_committing
input_api.tbr = tbr
input_api.dry_run = dry_run
......
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