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

Function locksCommand

commands/command_locks.go:20–132  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

18)
19
20func locksCommand(cmd *cobra.Command, args []string) {
21 lockData, err := computeLockData()
22 if err != nil {
23 ExitWithError(err)
24 }
25 filters, err := locksCmdFlags.Filters(lockData)
26 if err != nil {
27 Exit(tr.Tr.Get("Error building filters: %v", err))
28 }
29
30 if len(lockRemote) > 0 {
31 cfg.SetRemote(lockRemote)
32 }
33
34 refUpdate := git.NewRefUpdate(cfg.Git, cfg.PushRemote(), cfg.CurrentRef(), nil)
35 lockClient := newLockClient()
36 lockClient.RemoteRef = refUpdate.RemoteRef()
37 defer lockClient.Close()
38
39 if locksCmdFlags.Cached {
40 if locksCmdFlags.Limit > 0 {
41 Exit(tr.Tr.Get("--cached option can't be combined with --limit"))
42 }
43 if len(filters) > 0 {
44 Exit(tr.Tr.Get("--cached option can't be combined with filters"))
45 }
46 if locksCmdFlags.Local {
47 Exit(tr.Tr.Get("--cached option can't be combined with --local"))
48 }
49 }
50
51 if locksCmdFlags.Verify {
52 if len(filters) > 0 {
53 Exit(tr.Tr.Get("--verify option can't be combined with filters"))
54 }
55 if locksCmdFlags.Local {
56 Exit(tr.Tr.Get("--verify option can't be combined with --local"))
57 }
58 }
59
60 var locks []locking.Lock
61 var locksOwned map[locking.Lock]bool
62 var jsonWriteFunc func(io.Writer) error
63 if locksCmdFlags.Verify {
64 var ourLocks, theirLocks []locking.Lock
65 ourLocks, theirLocks, err = lockClient.SearchLocksVerifiable(locksCmdFlags.Limit, locksCmdFlags.Cached)
66 jsonWriteFunc = func(writer io.Writer) error {
67 return lockClient.EncodeLocksVerifiable(ourLocks, theirLocks, writer)
68 }
69
70 locks = append(ourLocks, theirLocks...)
71 locksOwned = make(map[locking.Lock]bool)
72 for _, lock := range ourLocks {
73 locksOwned[lock] = true
74 }
75 } else {
76 locks, err = lockClient.SearchLocks(filters, locksCmdFlags.Limit, locksCmdFlags.Local, locksCmdFlags.Cached)
77 jsonWriteFunc = func(writer io.Writer) error {

Callers

nothing calls this directly

Calls 15

RemoteRefMethod · 0.95
NewRefUpdateFunction · 0.92
CauseFunction · 0.92
computeLockDataFunction · 0.85
ExitWithErrorFunction · 0.85
ExitFunction · 0.85
newLockClientFunction · 0.85
ErrorFunction · 0.85
PrintFunction · 0.85
FiltersMethod · 0.80
SetRemoteMethod · 0.80
PushRemoteMethod · 0.80

Tested by

no test coverage detected