blob: 0ec53f49525412ba726716b4d20c31778d606f01 (
plain) (
blame)
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 commands
import (
"github.com/spf13/cobra"
"github.com/MichaelMure/git-bug/commands/execenv"
)
func newWipeCommand() *cobra.Command {
env := execenv.NewEnv()
cmd := &cobra.Command{
Use: "wipe",
Short: "Wipe git-bug from the git repository",
PreRunE: execenv.LoadBackend(env),
RunE: func(cmd *cobra.Command, args []string) error {
return runWipe(env)
},
}
return cmd
}
func runWipe(env *execenv.Env) error {
env.Out.Println("cleaning entities...")
err := env.Backend.RemoveAll()
if err != nil {
_ = env.Backend.Close()
return err
}
env.Out.Println("cleaning git config ...")
err = env.Backend.ClearUserIdentity()
if err != nil {
_ = env.Backend.Close()
return err
}
err = env.Backend.LocalConfig().RemoveAll("git-bug")
if err != nil {
_ = env.Backend.Close()
return err
}
storage := env.Backend.LocalStorage()
err = env.Backend.Close()
if err != nil {
return err
}
env.Out.Println("cleaning caches ...")
err = storage.RemoveAll(".")
if err != nil {
return err
}
return nil
}
|