2015-07-10 16:43:20 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/github/git-lfs/lfs"
|
|
|
|
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2015-08-29 04:14:06 +00:00
|
|
|
// uninitCmd removes any configuration and hooks set by Git LFS.
|
2015-07-10 16:43:20 +00:00
|
|
|
uninitCmd = &cobra.Command{
|
|
|
|
Use: "uninit",
|
|
|
|
Short: "Clear the Git LFS configuration",
|
|
|
|
Run: uninitCommand,
|
|
|
|
}
|
|
|
|
|
2015-08-29 04:14:06 +00:00
|
|
|
// uninitHooksCmd removes any hooks created by Git LFS.
|
2015-07-10 16:43:20 +00:00
|
|
|
uninitHooksCmd = &cobra.Command{
|
|
|
|
Use: "hooks",
|
2015-07-10 17:41:11 +00:00
|
|
|
Short: "Clear only the Git hooks for the current repository",
|
2015-07-10 16:43:20 +00:00
|
|
|
Run: uninitHooksCommand,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func uninitCommand(cmd *cobra.Command, args []string) {
|
2015-08-31 00:13:19 +00:00
|
|
|
if err := lfs.UninstallFilters(); err != nil {
|
2015-07-10 16:43:20 +00:00
|
|
|
Error(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
Print("Global Git LFS configuration has been removed.")
|
|
|
|
|
|
|
|
if lfs.InRepo() {
|
|
|
|
uninitHooksCommand(cmd, args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func uninitHooksCommand(cmd *cobra.Command, args []string) {
|
|
|
|
if err := lfs.UninstallHooks(); err != nil {
|
|
|
|
Error(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
Print("Hooks for this repository have been removed.")
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
uninitCmd.AddCommand(uninitHooksCmd)
|
|
|
|
RootCmd.AddCommand(uninitCmd)
|
|
|
|
}
|