diff --git a/locking/api.go b/locking/api.go index 90be7e1a..f92b9cb2 100644 --- a/locking/api.go +++ b/locking/api.go @@ -22,7 +22,7 @@ type lockRequest struct { // `.git/refs/origin/`. LatestRemoteCommit string `json:"latest_remote_commit"` // Committer is the individual that wishes to obtain the lock. - Committer Committer `json:"committer"` + Committer *Committer `json:"committer"` } // LockResponse encapsulates the information sent over the API in response to @@ -200,8 +200,8 @@ type Committer struct { Email string `json:"email"` } -func NewCommitter(name, email string) Committer { - return Committer{Name: name, Email: email} +func NewCommitter(name, email string) *Committer { + return &Committer{Name: name, Email: email} } // String implements the fmt.Stringer interface by returning a string diff --git a/locking/locks.go b/locking/locks.go index fa81d042..aaceea21 100644 --- a/locking/locks.go +++ b/locking/locks.go @@ -174,7 +174,7 @@ type Lock struct { Path string `json:"path"` // Committer is the identity of the person who holds the ownership of // this lock. - Committer Committer `json:"committer"` + Committer *Committer `json:"committer"` // LockedAt is the time at which this lock was acquired. LockedAt time.Time `json:"locked_at"` } diff --git a/locking/locks_test.go b/locking/locks_test.go index 80877f9b..b9fb05ec 100644 --- a/locking/locks_test.go +++ b/locking/locks_test.go @@ -32,11 +32,11 @@ func TestRefreshCache(t *testing.T) { w.Header().Set("Content-Type", "application/json") err = json.NewEncoder(w).Encode(lockList{ Locks: []Lock{ - Lock{Id: "99", Path: "folder/test3.dat", Committer: Committer{Name: "Alice", Email: "alice@wonderland.com"}}, - Lock{Id: "101", Path: "folder/test1.dat", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}}, - Lock{Id: "102", Path: "folder/test2.dat", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}}, - Lock{Id: "103", Path: "root.dat", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}}, - Lock{Id: "199", Path: "other/test1.dat", Committer: Committer{Name: "Charles", Email: "charles@incharge.com"}}, + Lock{Id: "99", Path: "folder/test3.dat", Committer: &Committer{Name: "Alice", Email: "alice@wonderland.com"}}, + Lock{Id: "101", Path: "folder/test1.dat", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}}, + Lock{Id: "102", Path: "folder/test2.dat", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}}, + Lock{Id: "103", Path: "root.dat", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}}, + Lock{Id: "199", Path: "other/test1.dat", Committer: &Committer{Name: "Charles", Email: "charles@incharge.com"}}, }, }) assert.Nil(t, err) @@ -74,9 +74,9 @@ func TestRefreshCache(t *testing.T) { // Sort locks for stable comparison sort.Sort(LocksById(locks)) assert.Equal(t, []Lock{ - Lock{Path: "folder/test1.dat", Id: "101", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, - Lock{Path: "folder/test2.dat", Id: "102", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, - Lock{Path: "root.dat", Id: "103", Committer: Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, + Lock{Path: "folder/test1.dat", Id: "101", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, + Lock{Path: "folder/test2.dat", Id: "102", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, + Lock{Path: "root.dat", Id: "103", Committer: &Committer{Name: "Fred", Email: "fred@bloggs.com"}, LockedAt: zeroTime}, }, locks) } diff --git a/test/test-locks.sh b/test/test-locks.sh index 52d7afe2..8abfaa5b 100755 --- a/test/test-locks.sh +++ b/test/test-locks.sh @@ -17,6 +17,7 @@ begin_test "list a single lock" GITLFSLOCKSENABLED=1 git lfs locks --path "f.dat" | tee locks.log grep "1 lock(s) matched query" locks.log grep "f.dat" locks.log + grep "Git LFS Tests " locks.log ) end_test @@ -34,6 +35,7 @@ begin_test "list a single lock (--json)" GITLFSLOCKSENABLED=1 git lfs locks --json --path "f_json.dat" | tee locks.log grep "\"path\":\"f_json.dat\"" locks.log + grep "\"committer\":{\"name\":\"Git LFS Tests\",\"email\":\"git-lfs@example.com\"}" locks.log ) end_test