[PRESUBMIT] Read DEPS file from Git in CheckForCommitObjects

CheckForCommitObjects is not working correctly if there is a
PanProjectChecks in non-root PRESUBMIT.py together with a DEPS file in
the same directory. Instead, PRESUBMIT needs to check the root DEPS
file.

In order to get commit objects (gitlink), we need to run Git ops.  This
patch relies on Git to provide the root DEPS file.

R=gavinmak@google.com

Fixed: 359944302
Change-Id: I7934a24c1ea8e6b6daa2f936ad4209ad9cdad5ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5784174
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
changes/74/5784174/3
Josip Sokcevic 11 months ago committed by LUCI CQ
parent 37a737c1bc
commit 0bc7c4832e

@ -1970,14 +1970,14 @@ def CheckForCommitObjects(input_api, output_api):
] ]
# Get DEPS file. # Get DEPS file.
deps_file = input_api.os_path.join(input_api.PresubmitLocalPath(), 'DEPS') try:
if not input_api.os_path.isfile(deps_file): deps_content = input_api.subprocess.check_output(
# No DEPS file, carry on! ['git', 'show', 'HEAD:DEPS'], cwd=input_api.PresubmitLocalPath())
deps = _ParseDeps(deps_content)
except Exception:
# No DEPS file, so skip this check.
return [] return []
with open(deps_file) as f:
deps_content = f.read()
deps = _ParseDeps(deps_content)
# set default # set default
if 'deps' not in deps: if 'deps' not in deps:
deps['deps'] = {} deps['deps'] = {}

Loading…
Cancel
Save