1 Star 0 Fork 1

wangzb/depot_tools

forked from prothesman/depot_tools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
repo 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Wrapper around repo to auto-update depot_tools during sync.
gclient keeps depot_tools up-to-date automatically for Chromium developers.
We only want to do this on `repo sync` operations as that implies a network
operation, and update_depot_tools is not cheap.
"""
import os
from pathlib import Path
import subprocess
import sys
import gclient_utils
# Some useful paths.
DEPOT_TOOLS_DIR = Path(__file__).resolve().parent
UPDATE_DEPOT_TOOLS = DEPOT_TOOLS_DIR / 'update_depot_tools'
REPO = DEPOT_TOOLS_DIR / 'repo_launcher'
def _UpdateDepotTools():
"""Help CrOS users keep their depot_tools checkouts up-to-date."""
if os.getenv('DEPOT_TOOLS_UPDATE') == '0':
return
# We don't update the copy that's part of the CrOS repo client checkout.
path = DEPOT_TOOLS_DIR
while path != path.parent:
if (path / '.repo').is_dir() and (path / 'chromite').is_dir():
return
if (path / '.citc').is_dir():
return
path = path.parent
if UPDATE_DEPOT_TOOLS.exists():
subprocess.run([UPDATE_DEPOT_TOOLS], check=True)
else:
print(
f'warning: {UPDATE_DEPOT_TOOLS} does not exist; export '
'DEPOT_TOOLS_UPDATE=0 to disable.',
file=sys.stderr)
def main(argv):
if gclient_utils.IsEnvCog():
print('"repo" is not supported in non-git environment.',
file=sys.stderr)
return 1
# This is a bit hacky, but should be "good enough". If repo itself gains
# support for sync hooks, we could switch to that.
if argv and argv[0] == 'sync':
_UpdateDepotTools()
os.execv(sys.executable, [sys.executable, str(REPO)] + argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangzb26/depot_tools.git
git@gitee.com:wangzb26/depot_tools.git
wangzb26
depot_tools
depot_tools
main

搜索帮助