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>
diff --git a/gclient.py b/gclient.py
index 471f431..ad0037d 100755
--- a/gclient.py
+++ b/gclient.py
@@ -2273,6 +2273,8 @@
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 @@
"""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')