diff --git a/.gitignore b/.gitignore index 8c1eb33..7fbcd10 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ conf/reply.php jdCookie.js scripts/node_modules task/* -*.repo \ No newline at end of file +*.repo +repos \ No newline at end of file diff --git a/models/repos.go b/models/repos.go index e84d586..4d32adf 100644 --- a/models/repos.go +++ b/models/repos.go @@ -13,8 +13,6 @@ type Repo struct { ok bool } -var reposPath = "" - func (rp *Repo) init() { rp.filename = strings.Replace(strings.Replace(strings.Replace(rp.Git, "https://", "", -1), "/", "_", -1), ".git", "", -1) if !rp.exist() { @@ -23,16 +21,15 @@ func (rp *Repo) init() { } func (rp *Repo) exist() bool { - if _, err := os.Stat(reposPath + "/" + rp.filename); err != nil { + if _, err := os.Stat(ExecPath + "/" + rp.filename); err != nil { return false } return true } func initRepos() { - reposPath = ExecPath + "/repos" - if _, err := os.Stat(reposPath); err != nil { - os.MkdirAll(reposPath, 777) + if _, err := os.Stat(ExecPath); err != nil { + os.MkdirAll(ExecPath, 777) } for _, repo := range Config.Repos { repo.init() @@ -41,7 +38,7 @@ func initRepos() { func (rp *Repo) gitClone() { cmd := exec.Command("sh", "-c", fmt.Sprintf("git clone %s %s", rp.Git, rp.filename)) - cmd.Path = reposPath + cmd.Path = ExecPath fmt.Println("sh", "-c", fmt.Sprintf("git clone %s %s", rp.Git, rp.filename)) fmt.Println(cmd.Output()) }