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

Function templatesClone

cli/cmd/init/local.go:284–314  ·  view source on GitHub ↗

clone模版repo

()

Source from the content-addressed store, hash-verified

282
283// clone模版repo
284func 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(`
292git checkout -- *
293git 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}

Callers 1

getTemplateSettingFunction · 0.70

Calls 2

IsExistMethod · 0.80
RealtimeMethod · 0.80

Tested by

no test coverage detected