git-lfs/commands/command_init.go

50 lines
734 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":
if err := c.hookInit(); err != nil {
Print("%s", err)
return
}
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() {
gitmedia.InstallFilters()
}
func (c *InitCommand) hookInit() error {
return gitmedia.InstallHooks(true)
}
func init() {
registerCommand("init", func(c *Command) RunnableCommand {
return &InitCommand{Command: c}
})
}