当前目录是否已经clone
(workSpaceDir string)
| 165 | |
| 166 | // 当前目录是否已经clone |
| 167 | func (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 | // 文件是否存在 |
| 183 | func (instance *SSHRemote) IsFileExist(filepath string) bool { |
no test coverage detected