clone模版repo
()
| 282 | |
| 283 | // clone模版repo |
| 284 | func templatesClone() error { |
| 285 | templatePath := common.PathJoin(config.SmartIdeHome, TMEPLATE_DIR_NAME) |
| 286 | templateGitPath := common.PathJoin(templatePath, ".git") |
| 287 | templatesGitIsExist := common.IsExist(templateGitPath) |
| 288 | |
| 289 | // 通过判断.git目录存在,执行git pull,保持最新 |
| 290 | if templatesGitIsExist { |
| 291 | err := common.EXEC.Realtime(` |
| 292 | git checkout -- * |
| 293 | git pull |
| 294 | `, templatePath) |
| 295 | if err != nil { |
| 296 | return err |
| 297 | } |
| 298 | |
| 299 | } else { |
| 300 | err := os.RemoveAll(templatePath) |
| 301 | if err != nil { |
| 302 | return err |
| 303 | } |
| 304 | |
| 305 | command := fmt.Sprintf("git clone %v %v", config.GlobalSmartIdeConfig.TemplateActualRepoUrl, templatePath) |
| 306 | err = common.EXEC.Realtime(command, "") |
| 307 | if err != nil { |
| 308 | return err |
| 309 | } |
| 310 | |
| 311 | } |
| 312 | |
| 313 | return nil |
| 314 | } |
no test coverage detected