Przeglądaj źródła

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>
Gavin Mak 4 lat temu
rodzic
commit
f6b414c578
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      gclient.py

+ 4 - 0
gclient.py

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