forked from cross-cpm/xrepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_sync.go
79 lines (73 loc) · 1.55 KB
/
cli_sync.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"fmt"
"log"
)
func cliCheckout(extfile string) {
externals := NewExternals(extfile)
externals.Load()
idx := 0
count := externals.Count()
externals.Foreach(func(url string, info *RepoInfo) {
idx = idx + 1
fmt.Printf("=== [%d/%d] checkout %s ...\n", idx, count, url)
e := NewCvs(url, info)
err := e.Checkout()
if err != nil {
log.Fatal(err)
}
})
}
func cliPull(extfile string) {
externals := NewExternals(extfile)
externals.Load()
idx := 0
count := externals.Count()
externals.Foreach(func(url string, info *RepoInfo) {
idx = idx + 1
fmt.Printf("=== [%d/%d] pull %s ...\n", idx, count, url)
e := NewCvs(url, info)
ref, err := e.Pull()
if err != nil {
log.Println(err)
}
if ref != info.Ref {
log.Printf("set configure to ref(%s)", ref)
info.Ref = ref
}
})
err := externals.Save()
if err != nil {
log.Fatal(err)
}
}
func cliPush(extfile string) {
externals := NewExternals(extfile)
externals.Load()
idx := 0
count := externals.Count()
externals.Foreach(func(url string, info *RepoInfo) {
idx = idx + 1
fmt.Printf("=== [%d/%d] push %s ...\n", idx, count, url)
e := NewCvs(url, info)
err := e.Push()
if err != nil {
log.Println(err)
}
})
}
func cliStatus(extfile string) {
externals := NewExternals(extfile)
externals.Load()
idx := 0
count := externals.Count()
externals.Foreach(func(url string, info *RepoInfo) {
idx = idx + 1
fmt.Printf("=== [%d/%d] status %s ...\n", idx, count, url)
e := NewCvs(url, info)
err := e.Status()
if err != nil {
log.Println(err)
}
})
}