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

Method parseLockResponse

locking/ssh.go:24–58  ·  view source on GitHub ↗
(status int, args []string, lines []string)

Source from the content-addressed store, hash-verified

22}
23
24func (c *sshLockClient) parseLockResponse(status int, args []string, lines []string) (*Lock, string, error) {
25 var lock *Lock
26 var message string
27 var err error
28 seen := make(map[string]struct{})
29 if status >= 200 && status <= 299 || status == 409 {
30 lock = &Lock{}
31 for _, entry := range args {
32 if strings.HasPrefix(entry, "id=") {
33 lock.Id = entry[3:]
34 seen["id"] = struct{}{}
35 } else if strings.HasPrefix(entry, "path=") {
36 lock.Path = entry[5:]
37 seen["path"] = struct{}{}
38 } else if strings.HasPrefix(entry, "ownername=") {
39 lock.Owner = &User{}
40 lock.Owner.Name = entry[10:]
41 seen["ownername"] = struct{}{}
42 } else if strings.HasPrefix(entry, "locked-at=") {
43 lock.LockedAt, err = time.Parse(time.RFC3339, entry[10:])
44 if err != nil {
45 return lock, "", errors.New(tr.Tr.Get("lock response: invalid locked-at: %s", entry))
46 }
47 seen["locked-at"] = struct{}{}
48 }
49 }
50 if len(seen) != 4 {
51 return nil, "", errors.New(tr.Tr.Get("incomplete fields for lock"))
52 }
53 }
54 if status > 299 && len(lines) > 0 {
55 message = lines[0]
56 }
57 return lock, message, nil
58}
59
60type owner string
61

Callers 2

LockMethod · 0.95
UnlockMethod · 0.95

Calls 2

NewFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected