mirror of
https://github.com/taigrr/mg.git
synced 2026-04-02 11:38:41 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f0c6f3906a | |||
| 01c736b54e |
1
cmd/mg/.gitignore
vendored
Normal file
1
cmd/mg/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
main
|
||||
@@ -40,14 +40,16 @@ var (
|
||||
for i := 0; i < jobs; i++ {
|
||||
go func() {
|
||||
for repo := range repoChan {
|
||||
_, err := git.PlainOpenWithOptions(repo.Remote, &(git.PlainOpenOptions{DetectDotGit: true}))
|
||||
_, err := git.PlainOpenWithOptions(repo.Path, &(git.PlainOpenOptions{DetectDotGit: true}))
|
||||
if err == nil {
|
||||
log.Printf("already cloned: %s\n", repo.Path)
|
||||
mutex.Lock()
|
||||
alreadyCloned++
|
||||
mutex.Unlock()
|
||||
wg.Done()
|
||||
continue
|
||||
} else if err == git.ErrRepositoryNotExists {
|
||||
log.Printf("attempting clone: %s\n", repo)
|
||||
log.Printf("attempting clone: %s\n", repo.Path)
|
||||
_, err = git.PlainClone(repo.Path, false, &git.CloneOptions{
|
||||
URL: repo.Remote,
|
||||
})
|
||||
@@ -59,24 +61,26 @@ var (
|
||||
wg.Done()
|
||||
continue
|
||||
}
|
||||
fmt.Printf("successfully cloned %s\n", repo)
|
||||
fmt.Printf("successfully cloned %s\n", repo.Path)
|
||||
wg.Done()
|
||||
continue
|
||||
} else {
|
||||
mutex.Lock()
|
||||
errs = append(errs, RepoError{Error: err, Repo: repo.Path})
|
||||
mutex.Unlock()
|
||||
log.Printf("clone failed for %s: %v\n", repo, err)
|
||||
log.Printf("clone failed for %s: %v\n", repo.Path, err)
|
||||
wg.Done()
|
||||
continue
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
fmt.Println(len(conf.Repos))
|
||||
for _, repo := range conf.Repos {
|
||||
repoChan <- repo
|
||||
}
|
||||
close(repoChan)
|
||||
fmt.Println("waiting...")
|
||||
wg.Wait()
|
||||
for _, err := range errs {
|
||||
log.Printf("error pulling %s: %s\n", err.Repo, err.Error)
|
||||
|
||||
Reference in New Issue
Block a user