From 314e46cf2c08d87e194e8447dc24b8910d55effb Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 9 May 2024 16:28:22 +0000 Subject: [PATCH] move is_env_cog to a dedicated helper function in gclient_util module So that it can be shared with code other than scm. Bug: 339231299 Change-Id: Iba68cc7ebba78c8933598d073861290bb0157c40 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5529883 Auto-Submit: Yiwei Zhang Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- gclient.py | 3 +-- gclient_utils.py | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gclient.py b/gclient.py index a14499d480..56f506ea70 100755 --- a/gclient.py +++ b/gclient.py @@ -1655,8 +1655,7 @@ class GitDependency(Dependency): def _IsCog(): """Returns true if the env is cog""" if GitDependency._is_env_cog is None: - GitDependency._is_env_cog = os.getcwd().startswith( - '/google/cog/cloud') + GitDependency._is_env_cog = gclient_utils.IsEnvCog() return GitDependency._is_env_cog diff --git a/gclient_utils.py b/gclient_utils.py index dadd208e09..00eb681d9a 100644 --- a/gclient_utils.py +++ b/gclient_utils.py @@ -1201,6 +1201,11 @@ def RunEditor(content, git, git_editor=None): os.remove(filename) +def IsEnvCog(): + """Returns whether the command is running in a Cog environment.""" + return os.getcwd().startswith('/google/cog/cloud') + + def UpgradeToHttps(url): """Upgrades random urls to https://.