MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / load

Method load

client/node/toolloader/gitload.py:114–141  ·  view source on GitHub ↗

从git拉取或更新一个代码仓库 :return:

(self)

Source from the content-addressed store, hash-verified

112 return None
113
114 def load(self):
115 """
116 从git拉取或更新一个代码仓库
117 :return:
118 """
119 try:
120 if os.path.exists(self._dest_dir): # 目录已存在
121 local_dir_scm = ScmClient(scm_type="git",
122 scm_url="",
123 source_dir=self._dest_dir,
124 scm_username="",
125 scm_password="")
126 if local_dir_scm.can_reuse_by(self._scm_url): # 可以复用
127 self.__retry_update()
128 else: # 不能复用,删除当前工具目录重新拉取
129 # logger.info(f"不能复用{self._dest_dir},删除当前工具目录重新拉取...")
130 PathMgr().safe_rmpath(self._dest_dir)
131 self.__retry_checkout()
132 else: # 目录不存在
133 dir_path = os.path.dirname(self._dest_dir)
134 if not os.path.exists(dir_path): # 如果上层目录不存在,先创建
135 os.makedirs(dir_path)
136 self.__retry_checkout()
137 except Exception as err:
138 raise NodeError(code=E_NODE_TASK_SCM_FAILED, msg=str(err))
139 finally:
140 # 删除临时保存的ssh key文件
141 SshFlieClient.remove_temp_ssh_file(self._ssh_temp_file)
142
143 def __retry_update(self):
144 try:

Callers 15

runMethod · 0.45
_load_dataMethod · 0.45
load_toolMethod · 0.45
_send_resultMethod · 0.45
load_configMethod · 0.45
get_task_result_pathsMethod · 0.45
get_scan_tasksMethod · 0.45
get_input_paramsMethod · 0.45
get_task_resultMethod · 0.45
upload_task_resultMethod · 0.45

Calls 5

__retry_updateMethod · 0.95
__retry_checkoutMethod · 0.95
ScmClientFunction · 0.90
NodeErrorClass · 0.90
can_reuse_byMethod · 0.45

Tested by 1

runMethod · 0.36