-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (46 loc) · 938 Bytes
/
main.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
package main
import (
"log"
"os"
"github.com/petr-korobeinikov/scm/internal/history"
scm "github.com/petr-korobeinikov/scm/internal"
)
func main() {
var err error
defer func() {
if err != nil {
log.Fatalln(err)
}
}()
if len(os.Args) == 2 && os.Args[1] == "last" {
err = history.LastRead()
return
}
scmBin, scmURL, scmOverridePostCloneCmd, err := scm.ParseArgs(os.Args)
if err != nil {
return
}
cfg, err := scm.Configure(scmURL, scmOverridePostCloneCmd)
if err != nil {
return
}
err = scm.PrepareLocalWorkingCopyPath(cfg.ScmWorkingCopyPath, cfg.ScmWorkspaceDirDefaultPerm)
if err != nil {
return
}
err = scm.Clone(scmBin, scmURL, cfg.ScmWorkingCopyPath)
if err != nil {
return
}
err = history.LastWrite(history.HistEntry{
Remote: scmURL,
Local: cfg.ScmWorkingCopyPath,
})
if err != nil {
return
}
err = scm.ExecutePostCmd(cfg.ScmPostCloneCmd)
if err != nil {
return
}
}