From da2ef92c9f15b97a75bf50ad5928e537b1651997 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 15 May 2024 21:30:51 +0000 Subject: [PATCH] fail gracefully if git map-branches is called in cog Bug: 339231299 Change-Id: I65c96463be51bb7da32b44c280d75622842612c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5540669 Commit-Queue: Josip Sokcevic Reviewed-by: Josip Sokcevic --- git_map_branches.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git_map_branches.py b/git_map_branches.py index 8b792f34c..c310dde73 100755 --- a/git_map_branches.py +++ b/git_map_branches.py @@ -33,6 +33,7 @@ from git_common import current_branch, upstream, tags, get_branches_info from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one from git_common import get_config, run +import gclient_utils import setup_color from third_party.colorama import Fore, Style @@ -339,6 +340,10 @@ def print_desc(): @metrics.collector.collect_metrics('git map-branches') def main(argv): + if gclient_utils.IsEnvCog(): + print('map-branches command is not supported in non-git environment.', + file=sys.stderr) + return 1 setup_color.init() if get_git_version() < MIN_UPSTREAM_TRACK_GIT_VERSION: print(