-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmain.go
74 lines (65 loc) · 1.7 KB
/
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"log"
"os"
"github.com/joho/godotenv"
"github.com/urfave/cli/v2"
)
var version = "0.0.0+0"
func main() {
app := cli.NewApp()
app.Name = "git plugin"
app.Usage = "git plugin"
app.Action = run
app.Version = version
app.Flags = globalFlags
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(c *cli.Context) error {
if c.String("env-file") != "" {
_ = godotenv.Load(c.String("env-file"))
}
plugin := Plugin{
Repo: Repo{
Clone: c.String("remote"),
CloneSSH: c.String("remote-ssh"),
ObjectFormat: c.String("object-format"),
},
Pipeline: Pipeline{
Commit: c.String("sha"),
Event: c.String("event"),
Path: c.String("path"),
Ref: c.String("ref"),
},
Netrc: Netrc{
Login: c.String("netrc.username"),
Machine: c.String("netrc.machine"),
Password: c.String("netrc.password"),
},
Config: Config{
Depth: c.Int("depth"),
Tags: c.Bool("tags"),
Recursive: c.Bool("recursive"),
SkipVerify: c.Bool("skip-verify"),
CustomCert: c.String("custom-cert"),
SubmoduleRemote: c.Bool("submodule-update-remote"),
Submodules: c.Generic("submodule-override").(*MapFlag).Get(),
SubmodulePartial: c.Bool("submodule-partial"),
Lfs: c.Bool("lfs"),
Branch: c.String("branch"),
Partial: c.Bool("partial"),
Home: c.String("home"),
SafeDirectory: c.String("safe-directory"),
UseSSH: c.Bool("use-ssh"),
SSHKey: c.String("ssh-key"),
},
Backoff: Backoff{
Attempts: c.Int("backoff-attempts"),
Duration: c.Duration("backoff"),
},
}
SetDefaults(c, &plugin)
return plugin.Exec()
}