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

Method Lock

locking/api.go:62–87  ·  view source on GitHub ↗
(remote string, lockReq *lockRequest)

Source from the content-addressed store, hash-verified

60}
61
62func (c *httpLockClient) Lock(remote string, lockReq *lockRequest) (*lockResponse, int, error) {
63 e := c.Endpoints.Endpoint("upload", remote)
64 req, err := c.NewRequest("POST", e, "locks", lockReq)
65 if err != nil {
66 return nil, 0, err
67 }
68
69 req = c.Client.LogRequest(req, "lfs.locks.lock")
70 res, err := c.DoAPIRequestWithAuth(remote, req)
71 if err != nil {
72 if res != nil {
73 return nil, res.StatusCode, err
74 }
75 return nil, 0, err
76 }
77
78 lockRes := &lockResponse{}
79 err = lfshttp.DecodeJSON(res, lockRes)
80 if err != nil {
81 return nil, res.StatusCode, err
82 }
83 if lockRes.Lock == nil && len(lockRes.Message) == 0 {
84 return nil, res.StatusCode, errors.New(tr.Tr.Get("invalid server response"))
85 }
86 return lockRes, res.StatusCode, nil
87}
88
89// UnlockRequest encapsulates the data sent in an API request to remove a lock.
90type unlockRequest struct {

Callers 1

TestAPILockFunction · 0.95

Calls 7

DecodeJSONFunction · 0.92
NewFunction · 0.92
DoAPIRequestWithAuthMethod · 0.80
EndpointMethod · 0.65
GetMethod · 0.65
NewRequestMethod · 0.45
LogRequestMethod · 0.45

Tested by 1

TestAPILockFunction · 0.76