From 6a7597cf9a2e74c21e6ae9764bde073c8e5295f4 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Tue, 14 May 2024 19:56:08 +0000 Subject: [PATCH] error if git cache commands are called in cog env. Bug: 339231299 Change-Id: I0baa6ba9836b0026fb5b5c27b17a72c6e4d7ecde Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5536289 Reviewed-by: Josip Sokcevic Auto-Submit: Yiwei Zhang Commit-Queue: Josip Sokcevic --- git_cache.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/git_cache.py b/git_cache.py index ec6d7656b..420578584 100755 --- a/git_cache.py +++ b/git_cache.py @@ -732,6 +732,11 @@ def CMDupdate_bootstrap(parser, args): file=sys.stderr) return 1 + if gclient_utils.IsEnvCog(): + print('updating bootstrap is not supported in non-git environment.', + file=sys.stderr) + return 1 + parser.add_option('--skip-populate', action='store_true', help='Skips "populate" step if mirror already exists.') @@ -763,6 +768,11 @@ def CMDupdate_bootstrap(parser, args): @metrics.collector.collect_metrics('git cache populate') def CMDpopulate(parser, args): """Ensure that the cache has all up-to-date objects for the given repo.""" + if gclient_utils.IsEnvCog(): + print('populating cache is not supported in non-git environment.', + file=sys.stderr) + return 1 + parser.add_option('--depth', type='int', help='Only cache DEPTH commits of history') @@ -826,6 +836,13 @@ def CMDpopulate(parser, args): @metrics.collector.collect_metrics('git cache fetch') def CMDfetch(parser, args): """Update mirror, and fetch in cwd.""" + if gclient_utils.IsEnvCog(): + print( + 'fetching new commits into cache is not supported in non-git ' + 'environment.', + file=sys.stderr) + return 1 + parser.add_option('--all', action='store_true', help='Fetch all remotes') parser.add_option('--no_bootstrap', '--no-bootstrap',