git-lfs/commands/command_init.go

51 lines
755 B
Go
Raw Normal View History

package commands
import (
"github.com/github/git-media/gitmedia"
)
type InitCommand struct {
*Command
}
func (c *InitCommand) Run() {
var sub string
if len(c.SubCommands) > 0 {
sub = c.SubCommands[0]
}
switch sub {
case "hooks":
2014-06-05 18:48:23 +00:00
c.hookInit()
default:
c.runInit()
}
Print("git media initialized")
}
func (c *InitCommand) runInit() {
c.globalInit()
2014-06-03 21:05:58 +00:00
if gitmedia.InRepo() {
c.hookInit()
}
}
func (c *InitCommand) globalInit() {
2014-06-05 18:48:23 +00:00
if err := gitmedia.InstallFilters(); err != nil {
Error(err.Error())
}
}
2014-06-05 18:48:23 +00:00
func (c *InitCommand) hookInit() {
if err := gitmedia.InstallHooks(); err != nil {
Error(err.Error())
}
}
func init() {
registerCommand("init", func(c *Command) RunnableCommand {
return &InitCommand{Command: c}
})
}