feat: 仓库接入通用化——批量预检 + 多仓 ssh 别名配给
This commit is contained in:
1 parent
0787496427
commit
50ba8d9297
3 files changed
+77
-3
No files matched your search
+25
-1
@@ -38,6 +38,7 @@ __all__ = [
|
||||
"checkout_dir",
|
||||
"resolve_repo",
|
||||
"check_repo_access",
|
||||
"check_repo_access_many",
|
||||
]
|
||||
|
||||
|
||||
@@ -203,10 +204,33 @@ def check_repo_access(repo_url, runner=None, timeout=30):
|
||||
return (True, head[0] if head else "")
|
||||
|
||||
|
||||
def check_repo_access_many(repo_urls, runner=None, timeout=30):
|
||||
"""批量预检:逐个调 check_repo_access,返回 {url: (ok, detail)}。
|
||||
|
||||
顺序与输入一致;单个失败不中断其余(批量预检的意义就是一次
|
||||
看清哪些仓通、哪些不通)。空列表返回空 dict。
|
||||
"""
|
||||
out = {}
|
||||
for url in repo_urls or []:
|
||||
out[url] = check_repo_access(url, runner=runner, timeout=timeout)
|
||||
return out
|
||||
|
||||
|
||||
def _main(argv):
|
||||
if len(argv) >= 3 and argv[1] == "check-many":
|
||||
results = check_repo_access_many(argv[2:])
|
||||
failed = 0
|
||||
for url, (ok, detail) in results.items():
|
||||
if ok:
|
||||
print("ok %s HEAD=%s" % (url, detail))
|
||||
else:
|
||||
failed += 1
|
||||
print("fail %s: %s" % (url, detail))
|
||||
return 1 if failed else 0
|
||||
if len(argv) != 3 or argv[1] != "check":
|
||||
sys.stderr.write(
|
||||
"用法: python3 -m cloud.repos check <repo_url>\n")
|
||||
"用法: python3 -m cloud.repos check <repo_url>\n"
|
||||
" python3 -m cloud.repos check-many <repo_url>...\n")
|
||||
return 2
|
||||
ok, detail = check_repo_access(argv[2])
|
||||
if ok:
|
||||
|
||||
Reference in new issue
Block a user