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"
|
2016-11-30 20:56:22 +00:00
|
|
|
"github.com/git-lfs/git-lfs/localstorage"
|
2016-05-23 18:02:27 +00:00
|
|
|
"github.com/spf13/cobra"
|
2015-11-16 20:37:08 +00:00
|
|
|
)
|
|
|
|
|
2016-08-10 15:33:25 +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) {
|
2017-01-24 23:33:29 +00:00
|
|
|
opt := cmdInstallOptions()
|
|
|
|
if err := lfs.UninstallFilters(opt); err != nil {
|
2015-11-16 20:37:08 +00:00
|
|
|
Error(err.Error())
|
|
|
|
}
|
|
|
|
|
2017-01-24 23:33:29 +00:00
|
|
|
if localInstall || lfs.InRepo() {
|
2016-11-30 20:56:22 +00:00
|
|
|
localstorage.InitStorageOrFail()
|
2015-11-16 20:37:08 +00:00
|
|
|
uninstallHooksCommand(cmd, args)
|
|
|
|
}
|
2017-01-24 23:33:29 +00:00
|
|
|
|
|
|
|
Print("Global Git LFS configuration has been removed.")
|
2015-11-16 20:37:08 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 15:33:25 +00:00
|
|
|
// 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() {
|
2016-09-01 16:09:38 +00:00
|
|
|
RegisterCommand("uninstall", uninstallCommand, func(cmd *cobra.Command) {
|
2017-01-24 23:33:29 +00:00
|
|
|
cmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Set the Git LFS config for the local Git repository only.")
|
|
|
|
cmd.Flags().BoolVarP(&systemInstall, "system", "", false, "Set the Git LFS config in system-wide scope.")
|
2016-09-01 14:46:26 +00:00
|
|
|
cmd.AddCommand(NewCommand("hooks", uninstallHooksCommand))
|
2016-11-30 20:56:22 +00:00
|
|
|
cmd.PreRun = setupLocalStorage
|
2016-08-10 15:33:25 +00:00
|
|
|
})
|
2015-11-16 20:37:08 +00:00
|
|
|
}
|