This commit is contained in:
cdle 2021-08-21 17:26:23 +08:00
parent 86cd136d92
commit 6ea0ee469f
2 changed files with 10 additions and 6 deletions

2
.gitignore vendored
View File

@ -23,4 +23,4 @@ conf/reply.php
jdCookie.js
scripts/node_modules
task/*
repos/*
repos

View File

@ -12,22 +12,26 @@ type Repo struct {
filename string
}
var reposPath = ""
func (rp *Repo) init() {
rp.filename = strings.Replace(strings.Replace(rp.Git, "https://", "", -1), "/", "_", -1)
}
func initRepos() {
reposPath = ExecPath + "/repos"
if _, err := os.Stat(reposPath); err != nil {
os.MkdirAll(reposPath, os.ModePerm)
}
for _, repo := range Config.Repos {
repo.init()
if _, err := os.Stat(ExecPath + "/" + repo.filename); err != nil {
if _, err := os.Stat(reposPath + "/" + repo.filename); err != nil {
repo.gitClone()
}
}
}
func (rp *Repo) gitClone() {
cmd := exec.Command("git", "clone", rp.Git, rp.filename)
cmd.Path = ExecPath + "/repos"
fmt.Println(cmd.Path)
fmt.Println(cmd.Start())
cmd := exec.Command("sh", "-c", fmt.Sprintf("git clone %s %s", rp.Git, rp.filename))
cmd.Output()
}