MCPcopy Create free account
hub / github.com/Tencent/CodeAnalysis / GitRemoteClient

Class GitRemoteClient

server/projects/main/util/scm/git.py:24–199  ·  view source on GitHub ↗

Git 远程客户端 - 通过 GitProxy 获取项目信息

Source from the content-addressed store, hash-verified

22
23
24class GitRemoteClient(IScmClient):
25 """Git 远程客户端 - 通过 GitProxy 获取项目信息"""
26
27 def __init__(self, scm_url, username=None, password=None, ssh_key=None, ssh_password=None, scm_platform_name=None):
28 """
29 初始化函数
30
31 :param scm_url: scm库地址
32 :param username: 域帐号
33 :param password: 密码
34 :param ssh_key: 私钥
35 :param ssh_password: 私钥口令
36 """
37 self._scm_url = scm_url.strip()
38 if ssh_key:
39 self._scm_info = {
40 "scm_type": "ssh+git",
41 "scm_url": self.get_ssh_url(),
42 "ssh_key": ssh_key,
43 "ssh_password": ssh_password
44 }
45 elif username == "oauth2":
46 self._scm_info = {
47 "scm_type": "git-oauth",
48 "scm_platform": scm_platform_name,
49 "scm_url": self.get_http_url(),
50 "username": username,
51 "password": password,
52 }
53 else:
54 self._scm_info = {
55 "scm_type": "git",
56 "scm_url": self.get_http_url(),
57 "username": username,
58 "password": password
59 }
60 self._git_proxy = CustomServerProxy(settings.SCMPROXY, timeout=int(settings.SCMPROXY_TIMEOUT))
61 self._repository = None
62 self._branch = None
63
64 @property
65 def latest_revision(self):
66 """最新版本号
67 """
68 return self._git_proxy.latest_revision(self._scm_info)
69
70 @property
71 def start_revision(self):
72 """最初版本号
73 """
74 return self._git_proxy.start_revision(self._scm_info)
75
76 def get_repository(self):
77 """代码库地址
78 """
79 scm_url = self._scm_info["scm_url"].rstrip("/")
80 return ScmUrlFormatter.get_git_url(scm_url)
81

Callers 1

ScmClientFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected