git-lfs/commands/command_uninstall.go

38 lines
927 B
Go
Raw Normal View History

2015-11-16 20:37:08 +00:00
package commands
import (
2016-11-15 17:01:18 +00:00
"github.com/git-lfs/git-lfs/lfs"
"github.com/git-lfs/git-lfs/localstorage"
"github.com/spf13/cobra"
2015-11-16 20:37:08 +00:00
)
// uninstallCmd removes any configuration and hooks set by Git LFS.
2015-11-16 20:37:08 +00:00
func uninstallCommand(cmd *cobra.Command, args []string) {
if err := lfs.UninstallFilters(); err != nil {
Error(err.Error())
}
Print("Global Git LFS configuration has been removed.")
if lfs.InRepo() {
localstorage.InitStorageOrFail()
2015-11-16 20:37:08 +00:00
uninstallHooksCommand(cmd, args)
}
}
// uninstallHooksCmd removes any hooks created by Git LFS.
2015-11-16 20:37:08 +00:00
func uninstallHooksCommand(cmd *cobra.Command, args []string) {
if err := lfs.UninstallHooks(); err != nil {
Error(err.Error())
}
Print("Hooks for this repository have been removed.")
}
func init() {
RegisterCommand("uninstall", uninstallCommand, func(cmd *cobra.Command) {
cmd.AddCommand(NewCommand("hooks", uninstallHooksCommand))
cmd.PreRun = setupLocalStorage
})
2015-11-16 20:37:08 +00:00
}