MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / IsCloned

Method IsCloned

cli/pkg/common/sshremote.go:167–180  ·  view source on GitHub ↗

当前目录是否已经clone

(workSpaceDir string)

Source from the content-addressed store, hash-verified

165
166// 当前目录是否已经clone
167func (instance *SSHRemote) IsCloned(workSpaceDir string) bool {
168 gitDirPath := strings.Replace(FilePahtJoin4Linux(workSpaceDir, ".git"), "~/", "", -1) // 把路径变成 “a/b/c” 的形式,不支持 “./a/b/c”、“~/a/b/c”、“./a/b/c”
169 cloneCommand := fmt.Sprintf(`[[ -d "%v" ]] && echo "1" || echo "0"`,
170 gitDirPath)
171 outContent, err := instance.ExeSSHCommand(cloneCommand)
172 CheckError(err)
173
174 // .git 文件夹不存在,清空文件夹
175 if outContent == "0" {
176 instance.ExeSSHCommand("sudo rm -rf " + workSpaceDir)
177 }
178
179 return outContent == "1"
180}
181
182// 文件是否存在
183func (instance *SSHRemote) IsFileExist(filepath string) bool {

Callers 3

GitCloneMethod · 0.95
RemoveRemoteFunction · 0.95
ExecuteVmStartCmdFunction · 0.95

Calls 3

ExeSSHCommandMethod · 0.95
FilePahtJoin4LinuxFunction · 0.85
CheckErrorFunction · 0.85

Tested by

no test coverage detected