2014-09-23 21:42:47 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2015-03-19 19:30:55 +00:00
|
|
|
"github.com/github/git-lfs/lfs"
|
2015-05-25 18:20:50 +00:00
|
|
|
"github.com/github/git-lfs/vendor/_nuts/github.com/spf13/cobra"
|
2014-09-23 21:42:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
updateCmd = &cobra.Command{
|
|
|
|
Use: "update",
|
2015-03-19 19:30:55 +00:00
|
|
|
Short: "Update local Git LFS configuration",
|
2014-09-23 21:42:47 +00:00
|
|
|
Run: updateCommand,
|
|
|
|
}
|
2015-04-24 17:33:22 +00:00
|
|
|
|
|
|
|
updateForce = false
|
2014-09-23 21:42:47 +00:00
|
|
|
)
|
|
|
|
|
2015-03-19 19:30:55 +00:00
|
|
|
// updateCommand is used for updating parts of Git LFS that reside under
|
|
|
|
// .git/lfs.
|
2014-09-23 21:42:47 +00:00
|
|
|
func updateCommand(cmd *cobra.Command, args []string) {
|
|
|
|
updatePrePushHook()
|
|
|
|
}
|
|
|
|
|
2014-09-24 17:10:29 +00:00
|
|
|
// updatePrePushHook will force an update of the pre-push hook.
|
2014-09-23 21:42:47 +00:00
|
|
|
func updatePrePushHook() {
|
2015-04-24 17:33:22 +00:00
|
|
|
if err := lfs.InstallHooks(updateForce); err != nil {
|
|
|
|
Error(err.Error())
|
|
|
|
Print("Run `git lfs update --force` to overwrite this hook.")
|
|
|
|
} else {
|
|
|
|
Print("Updated pre-push hook")
|
|
|
|
}
|
|
|
|
|
2014-09-23 21:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2015-04-24 17:33:22 +00:00
|
|
|
updateCmd.Flags().BoolVarP(&updateForce, "force", "f", false, "Overwrite hooks.")
|
2014-09-23 21:42:47 +00:00
|
|
|
RootCmd.AddCommand(updateCmd)
|
|
|
|
}
|