github.com/q2/git-lfs@v0.5.1-0.20150410234700-03a0d4cec40e/commands/command_init.go (about) 1 package commands 2 3 import ( 4 "github.com/github/git-lfs/lfs" 5 "github.com/spf13/cobra" 6 ) 7 8 var ( 9 initCmd = &cobra.Command{ 10 Use: "init", 11 Short: "Initialize the default Git LFS configuration", 12 Run: initCommand, 13 } 14 15 initHooksCmd = &cobra.Command{ 16 Use: "hooks", 17 Short: "Initialize hooks for the current repository", 18 Run: initHooksCommand, 19 } 20 ) 21 22 func initCommand(cmd *cobra.Command, args []string) { 23 if err := lfs.InstallFilters(); err != nil { 24 Error(err.Error()) 25 } 26 27 if lfs.InRepo() { 28 initHooksCommand(cmd, args) 29 } 30 31 Print("git lfs initialized") 32 } 33 34 func initHooksCommand(cmd *cobra.Command, args []string) { 35 if err := lfs.InstallHooks(false); err != nil { 36 Error(err.Error()) 37 } 38 } 39 40 func init() { 41 initCmd.AddCommand(initHooksCmd) 42 RootCmd.AddCommand(initCmd) 43 }