Really fix requirement checking.
- Don't show the present-in-multiple files message unless it really is. - Don't error on the target branch. - Do error on the branch being submitted. - Output what files we've looked at. - Output what branch we're looking at. Change-Id: I1d254c42e0bc2550ceeb768532448b5797d87caf
This commit is contained in:
parent
d8b15436c8
commit
1508a4c88c
@ -56,9 +56,11 @@ class RequirementsList(object):
|
|||||||
- each has a list of Requirements objects
|
- each has a list of Requirements objects
|
||||||
- duplicates are not permitted within that list
|
- duplicates are not permitted within that list
|
||||||
"""
|
"""
|
||||||
|
print("Checking %(name)s" % {'name': self.name})
|
||||||
# First, parse.
|
# First, parse.
|
||||||
reqs = collections.defaultdict(set)
|
reqs = collections.defaultdict(set)
|
||||||
for fname, content in self.project.get('requirements', {}).items():
|
for fname, content in self.project.get('requirements', {}).items():
|
||||||
|
print("Processing %(fname)s" % {'fname': fname})
|
||||||
if strict and not content.endswith('\n'):
|
if strict and not content.endswith('\n'):
|
||||||
raise Exception("Requirements file %s does not "
|
raise Exception("Requirements file %s does not "
|
||||||
"end with a newline." % fname)
|
"end with a newline." % fname)
|
||||||
@ -68,12 +70,18 @@ class RequirementsList(object):
|
|||||||
if not name:
|
if not name:
|
||||||
# Comments and other unprocessed lines
|
# Comments and other unprocessed lines
|
||||||
continue
|
continue
|
||||||
|
if name in reqs:
|
||||||
print("Requirement %s present in multiple files" % name)
|
print("Requirement %s present in multiple files" % name)
|
||||||
if strict and name in reqs and not '-py' in fname:
|
if strict and not '-py' in fname:
|
||||||
|
if not self.failed:
|
||||||
self.failed = True
|
self.failed = True
|
||||||
|
print(
|
||||||
|
"Marking %(name)s as failed - dupe in %(fname)s."
|
||||||
|
% {'name': self.name, 'fname': fname})
|
||||||
reqs[name].update(r for (r, line) in entries)
|
reqs[name].update(r for (r, line) in entries)
|
||||||
|
|
||||||
for name, content in project.extras(self.project):
|
for name, content in project.extras(self.project):
|
||||||
|
print("Processing .[%(extra)s]" % {'extra': name})
|
||||||
parsed = requirement.parse(content)
|
parsed = requirement.parse(content)
|
||||||
for name, entries in parsed.items():
|
for name, entries in parsed.items():
|
||||||
reqs[name].update(r for (r, line) in entries)
|
reqs[name].update(r for (r, line) in entries)
|
||||||
@ -158,7 +166,7 @@ def main():
|
|||||||
head = run_command("git rev-parse HEAD")[0]
|
head = run_command("git rev-parse HEAD")[0]
|
||||||
head_proj = project.read(cwd)
|
head_proj = project.read(cwd)
|
||||||
head_reqs = RequirementsList('HEAD', head_proj)
|
head_reqs = RequirementsList('HEAD', head_proj)
|
||||||
head_reqs.process(strict=False)
|
head_reqs.process()
|
||||||
|
|
||||||
if not args.local:
|
if not args.local:
|
||||||
# build a list of requirements already in the target branch,
|
# build a list of requirements already in the target branch,
|
||||||
@ -172,7 +180,8 @@ def main():
|
|||||||
else:
|
else:
|
||||||
branch_proj = {'root': cwd}
|
branch_proj = {'root': cwd}
|
||||||
branch_reqs = RequirementsList(branch, branch_proj)
|
branch_reqs = RequirementsList(branch, branch_proj)
|
||||||
branch_reqs.process()
|
# Don't error on the target branch being broken.
|
||||||
|
branch_reqs.process(strict=False)
|
||||||
|
|
||||||
# iterate through the changing entries and see if they match the global
|
# iterate through the changing entries and see if they match the global
|
||||||
# equivalents we want enforced
|
# equivalents we want enforced
|
||||||
|
Loading…
Reference in New Issue
Block a user