-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmd_sync.go
65 lines (60 loc) · 1.2 KB
/
cmd_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
package main
import (
"fmt"
"gita/exec"
"gita/gitlib"
cli "github.com/urfave/cli/v2"
)
var cmdSync = &cli.Command{
Name: "sync",
Aliases: []string{},
Usage: "sync branch",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "src",
Aliases: []string{"s"},
Usage: "source branch.",
Required: false,
},
&cli.StringSliceFlag{
Name: "dst",
Aliases: []string{"t"},
Usage: "destination branches.",
Required: false,
},
&cli.StringSliceFlag{
Name: "tx",
Aliases: []string{"tX"},
Usage: "no use to hide flag t.",
Required: false,
},
&cli.BoolFlag{
Name: "realDoSync",
Aliases: []string{},
Usage: "really do sync action",
Required: false,
},
},
Description: `
`,
Action: func(c *cli.Context) error {
src := c.String("src")
dst := c.StringSlice("dst")
realDoSync := c.Bool("realDoSync")
if src == "" {
gitlib.Fetch()
return exec.ShellExecute(gitlib.CmdBranchesGraph)
}
if len(dst) == 0 {
return fmt.Errorf("missing dst flag")
}
bg, err := gitlib.GetBranchesGraph()
if err != nil {
return err
}
if err := bg.SyncBranchList(src, dst, realDoSync); err != nil {
return err
}
return nil
},
}