Commit e3b1c3d1 authored by dpranke@chromium.org's avatar dpranke@chromium.org

Fix swapping of args in call to relpath() that was causing

OWNERS checks on DEPS to fail.

TBR=maruel@chromium.org
BUG=157022



git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@163192 0039d316-1c4b-4281-b951-d872f2087c98
parent 79540058
......@@ -224,8 +224,11 @@ class Database(object):
glob_string = m.group(1)
directive = m.group(2)
full_glob_string = self.os_path.join(self.root, dirpath, glob_string)
if self.os_path.sep in glob_string:
raise SyntaxErrorInOwnersFile(owners_path, lineno,
'per-file globs cannot span directories: "%s"' % line)
baselines = self.glob(full_glob_string)
for baseline in (self.os_path.relpath(self.root, b) for b in baselines):
for baseline in (self.os_path.relpath(b, self.root) for b in baselines):
self._add_entry(baseline, directive, "per-file line",
owners_path, lineno)
continue
......
......@@ -316,8 +316,8 @@ def CheckLongLines(input_api, output_api, maxlen=80, source_file_filter=None):
"""Checks that there aren't any lines longer than maxlen characters in any of
the text files to be submitted.
"""
maxlens = {
'java': 100,
maxlens = {
'java': 100,
'': maxlen,
}
# Note: these are C++ specific but processed on all languages. :(
......
......@@ -79,7 +79,8 @@ class MockFileSystem(object):
return self.files[path]
@staticmethod
def relpath(base, path):
if path.startswith(base):
return path[len(base):]
return path
def relpath(path, base):
# This implementation is wrong in many ways; assert to check them for now.
assert path.startswith(base)
assert base.endswith('/')
return path[len(base):]
......@@ -173,6 +173,20 @@ class OwnersDatabaseTest(unittest.TestCase):
[tom],
['content/baz'])
def test_per_file_wildcard(self):
self.files['/OWNERS'] = 'per-file DEPS=*\n'
self.assert_dirs_not_covered_by(['DEPS'], [brett], [])
def test_mock_relpath(self):
# This test ensures the mock relpath has the arguments in the right
# order; this should probably live someplace else.
self.assertEquals(self.repo.relpath('foo/bar.c', 'foo/'), 'bar.c')
self.assertEquals(self.repo.relpath('/bar.c', '/'), 'bar.c')
def test_per_file_glob_across_dirs_not_allowed(self):
self.files['/OWNERS'] = 'per-file content/*=john@example.org\n'
self.assertRaises(owners.SyntaxErrorInOwnersFile,
self.db().directories_not_covered_by, ['DEPS'], [brett])
def assert_reviewers_for(self, files, expected_reviewers):
db = self.db()
......
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