1package cmdjson
2
3import (
4 "time"
5
6 "github.com/MichaelMure/git-bug/cache"
7 "github.com/MichaelMure/git-bug/entity"
8 "github.com/MichaelMure/git-bug/util/lamport"
9)
10
11type Identity struct {
12 Id string `json:"id"`
13 HumanId string `json:"human_id"`
14 Name string `json:"name"`
15 Login string `json:"login"`
16}
17
18func NewIdentity(i entity.Interface) Identity {
19 return Identity{
20 Id: i.Id().String(),
21 HumanId: i.Id().Human(),
22 Name: i.Name(),
23 Login: i.Login(),
24 }
25}
26
27func NewIdentityFromExcerpt(excerpt *cache.IdentityExcerpt) Identity {
28 return Identity{
29 Id: excerpt.Id().String(),
30 HumanId: excerpt.Id().Human(),
31 Name: excerpt.Name,
32 Login: excerpt.Login,
33 }
34}
35
36type Time struct {
37 Timestamp int64 `json:"timestamp"`
38 Time time.Time `json:"time"`
39 Lamport lamport.Time `json:"lamport,omitempty"`
40}
41
42func NewTime(t time.Time, l lamport.Time) Time {
43 return Time{
44 Timestamp: t.Unix(),
45 Time: t,
46 Lamport: l,
47 }
48}