Add client not configured message to gclient validate and flatten

Running gclient validate or gclient flatten outside of gclient root
results in an unhelpful AttributeError stacktrace. This change adds an
error message that lets the user know the client is not confugred.

Bug: 732733
Change-Id: I33b1a08aa394145e238a4939bfd995ec33a8df17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2624351
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
changes/51/2624351/2
Gavin Mak 4 years ago committed by LUCI CQ
parent 59b0ce20d3
commit f6b414c578

@ -2273,6 +2273,8 @@ def CMDflatten(parser, args):
options.nohooks = True
options.process_all_deps = True
client = GClient.LoadCurrentConfig(options)
if not client:
raise gclient_utils.Error('client not configured; see \'gclient config\'')
# Only print progress if we're writing to a file. Otherwise, progress updates
# could obscure intended output.
@ -2758,6 +2760,8 @@ def CMDvalidate(parser, args):
"""Validates the .gclient and DEPS syntax."""
options, args = parser.parse_args(args)
client = GClient.LoadCurrentConfig(options)
if not client:
raise gclient_utils.Error('client not configured; see \'gclient config\'')
rv = client.RunOnDeps('validate', args)
if rv == 0:
print('validate: SUCCESS')

Loading…
Cancel
Save