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

Method searchRemoteLocks

locking/locks.go:343–386  ·  view source on GitHub ↗
(filter map[string]string, limit int)

Source from the content-addressed store, hash-verified

341}
342
343func (c *Client) searchRemoteLocks(filter map[string]string, limit int) ([]Lock, error) {
344 locks := make([]Lock, 0, limit)
345
346 apifilters := make([]lockFilter, 0, len(filter))
347 for k, v := range filter {
348 apifilters = append(apifilters, lockFilter{Property: k, Value: v})
349 }
350
351 query := &lockSearchRequest{
352 Filters: apifilters,
353 Limit: limit,
354 Refspec: c.RemoteRef.Refspec(),
355 }
356
357 for {
358 list, _, err := c.client.Search(c.Remote, query)
359 if err != nil {
360 return locks, errors.Wrap(err, tr.Tr.Get("locking"))
361 }
362
363 if list.Message != "" {
364 if len(list.RequestID) > 0 {
365 tracerx.Printf("Server Request ID: %s", list.RequestID)
366 }
367 return locks, errors.New(tr.Tr.Get("server error searching for locks: %s", list.Message))
368 }
369
370 for _, l := range list.Locks {
371 locks = append(locks, l)
372 if limit > 0 && len(locks) >= limit {
373 // Exit outer loop too
374 return locks, nil
375 }
376 }
377
378 if list.NextCursor != "" {
379 query.Cursor = list.NextCursor
380 } else {
381 break
382 }
383 }
384
385 return locks, nil
386}
387
388// lockIdFromPath makes a call to the LFS API and resolves the ID for the locked
389// locked at the given path.

Callers 2

SearchLocksMethod · 0.95

Calls 5

WrapFunction · 0.92
NewFunction · 0.92
RefspecMethod · 0.80
SearchMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected