replace_url.py 849 字节
Newer Older
P
dev  
prgrmz01@163.com 已提交
1 2
import sys
from typing import List
ziix's avatar
ziix 已提交
3

P
dev  
prgrmz01@163.com 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
"""
# $* : -c advice.detachedHead=false clone --depth 1 --branch main https://github.com/frida/glib.git glib
# new_args : -c advice.detachedHead=false clone --depth 1 --branch main git@gitcode.net/dependency/frida/glib.git glib
"""
"""
['D:\\pubx\\git-replace\\replace_url.py', '-c', 'advice.detachedHead=false', 'clone', '--depth', '1', '--branch', 'main', 'https://github.com/frida/glib.git', 'glib']
"""
from repo_map import repo_url_map

def processWordK(wordK:str)->str:
    if wordK.startswith("https://github.com"):
        if repo_url_map.__contains__(wordK):
            return repo_url_map.__getitem__(wordK)
        else:
            return wordK
    else:
        return wordK

new_list:List[str]=list(map(lambda wordK:processWordK(wordK), sys.argv[1:]))
new_arg:str=" ".join(new_list)
print(new_arg)