-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmd_clean.go
58 lines (53 loc) · 1.15 KB
/
cmd_clean.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
package main
import (
"gita/exec"
"gita/gitlib"
cli "github.com/urfave/cli/v2"
)
var cmdClean = &cli.Command{
Name: "clean",
Aliases: []string{},
Usage: "clean local isolate branch.",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "view",
Aliases: []string{"v"},
Usage: "view branches only.",
},
&cli.BoolFlag{
Name: "untrack",
Aliases: []string{},
Usage: "force untrack isolate local branch.",
},
&cli.BoolFlag{
Name: "forceRemove",
Aliases: []string{},
Usage: "force remove isolate local branch.",
},
&cli.BoolFlag{
Name: "confirmRemove",
Aliases: []string{},
Usage: "confirm remove isolate local branch. -D",
},
},
Description: `
git getch
git branch -a
git branch --unset-upstream
git branch -d <branch>
`,
Action: func(c *cli.Context) error {
if c.Bool("view") {
gitlib.Fetch()
return exec.ShellExecute("git branch -a")
}
untrack := c.Bool("untrack")
forceRemove := c.Bool("forceRemove")
confirmRemove := c.Bool("confirmRemove")
_, err := gitlib.CleanMissingRemoteBranches(untrack, forceRemove, confirmRemove)
if err != nil {
return err
}
return nil
},
}