updateCommand is used for updating parts of Git LFS that reside under .git/lfs.
(cmd *cobra.Command, args []string)
| 15 | // updateCommand is used for updating parts of Git LFS that reside under |
| 16 | // .git/lfs. |
| 17 | func updateCommand(cmd *cobra.Command, args []string) { |
| 18 | requireGitVersion() |
| 19 | setupRepository() |
| 20 | |
| 21 | lfsAccessRE := regexp.MustCompile(`\Alfs\.(.*)\.access\z`) |
| 22 | for key, _ := range cfg.Git.All() { |
| 23 | matches := lfsAccessRE.FindStringSubmatch(key) |
| 24 | if len(matches) < 2 { |
| 25 | continue |
| 26 | } |
| 27 | |
| 28 | value, _ := cfg.Git.Get(key) |
| 29 | |
| 30 | switch value { |
| 31 | case "basic": |
| 32 | case "private": |
| 33 | cfg.SetGitLocalKey(key, "basic") |
| 34 | Print(tr.Tr.Get("Updated %s access from %s to %s.", matches[1], value, "basic")) |
| 35 | default: |
| 36 | cfg.UnsetGitLocalKey(key) |
| 37 | Print(tr.Tr.Get("Removed invalid %s access of %s.", matches[1], value)) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if updateForce && updateManual { |
| 42 | Exit(tr.Tr.Get("You cannot use --force and --manual options together")) |
| 43 | } |
| 44 | |
| 45 | if updateManual { |
| 46 | Print(getHookInstallSteps()) |
| 47 | } else { |
| 48 | if err := installHooks(updateForce); err != nil { |
| 49 | Error(err.Error()) |
| 50 | Exit("%s\n 1: %s\n 2: %s", |
| 51 | tr.Tr.Get("To resolve this, either:"), |
| 52 | tr.Tr.Get("run `git lfs update --manual` for instructions on how to merge hooks."), |
| 53 | tr.Tr.Get("run `git lfs update --force` to overwrite your hook.")) |
| 54 | } else { |
| 55 | Print(tr.Tr.Get("Updated Git hooks.")) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | } |
| 60 | |
| 61 | func init() { |
| 62 | RegisterCommand("update", updateCommand, func(cmd *cobra.Command) { |
no test coverage detected