mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-17 13:10:17 +03:00
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
|
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
|
||
|
}
|