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

Function postCheckoutCommand

commands/command_post_checkout.go:23–49  ·  view source on GitHub ↗

postCheckoutCommand is run through Git's post-checkout hook. The hook passes up to 3 arguments on the command line: 1. SHA of previous commit before the checkout 2. SHA of commit just checked out 3. Flag ("0" or "1") - 1 if a branch/tag/SHA was checked out, 0 if a file was In the case of a file bei

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

Source from the content-addressed store, hash-verified

21// This hook checks that files which are lockable and not locked are made read-only,
22// optimising that as best it can based on the available information.
23func postCheckoutCommand(cmd *cobra.Command, args []string) {
24 if len(args) != 3 {
25 Print(tr.Tr.Get("This should be run through Git's post-checkout hook. Run `git lfs update` to install it."))
26 os.Exit(1)
27 }
28
29 // Skip entire hook if lockable read only feature is disabled
30 if !cfg.SetLockableFilesReadOnly() {
31 os.Exit(0)
32 }
33
34 requireGitVersion()
35
36 lockClient := newLockClient()
37
38 // Skip this hook if no lockable patterns have been configured
39 if len(lockClient.GetLockablePatterns()) == 0 {
40 os.Exit(0)
41 }
42
43 if args[2] == "1" && args[0] != "0000000000000000000000000000000000000000" {
44 postCheckoutRevChange(lockClient, args[0], args[1])
45 } else {
46 postCheckoutFileChange(lockClient)
47 }
48
49}
50
51func postCheckoutRevChange(client *locking.Client, pre, post string) {
52 tracerx.Printf("post-checkout: changes between %v and %v", pre, post)

Callers

nothing calls this directly

Calls 8

PrintFunction · 0.85
requireGitVersionFunction · 0.85
newLockClientFunction · 0.85
postCheckoutRevChangeFunction · 0.85
postCheckoutFileChangeFunction · 0.85
GetLockablePatternsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected