Commit 04cf3de9 authored by Dirk Pranke's avatar Dirk Pranke Committed by LUCI CQ

Fix a Py3 bug in presubmit_canned_checks.py.

There were a couple of references to using filter() that
needed to be replaced with list comprehensions as the return
values may be used repeatedly.

Bug: 1207012
Change-Id: Iae0abd38aeb186d6f7945f8c848c1f7312cb45bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2890329Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
parent 3b9d2d85
......@@ -1510,12 +1510,12 @@ def CheckForCommitObjects(input_api, output_api):
full_tree = input_api.subprocess.check_output(
['git', 'ls-tree', '-r', '--full-tree', 'HEAD'],
cwd=input_api.PresubmitLocalPath()
)
).decode('utf8')
tree_entries = full_tree.split('\n')
tree_entries = filter(lambda x: len(x) > 0, tree_entries)
tree_entries = [x for x in tree_entries if len(x) > 0]
tree_entries = map(parse_tree_entry, tree_entries)
bad_tree_entries = filter(lambda x: x[1] == 'commit', tree_entries)
bad_tree_entries = map(lambda x: x[3], bad_tree_entries)
bad_tree_entries = [x for x in tree_entries if x[1] == 'commit']
bad_tree_entries = [x[3] for x in bad_tree_entries]
if len(bad_tree_entries) > 0:
return [output_api.PresubmitError(
'Commit objects present within tree.\n'
......
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