MCPcopy
hub / github.com/git-lfs/git-lfs / updateCommand

Function updateCommand

commands/command_update.go:17–59  ·  view source on GitHub ↗

updateCommand is used for updating parts of Git LFS that reside under .git/lfs.

(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

15// updateCommand is used for updating parts of Git LFS that reside under
16// .git/lfs.
17func 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
61func init() {
62 RegisterCommand("update", updateCommand, func(cmd *cobra.Command) {

Callers 1

installHooksCommandFunction · 0.85

Calls 12

requireGitVersionFunction · 0.85
setupRepositoryFunction · 0.85
PrintFunction · 0.85
ExitFunction · 0.85
getHookInstallStepsFunction · 0.85
installHooksFunction · 0.85
ErrorFunction · 0.85
SetGitLocalKeyMethod · 0.80
UnsetGitLocalKeyMethod · 0.80
AllMethod · 0.65
GetMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected