diff options
author | Michael Muré <batolettre@gmail.com> | 2019-08-11 14:08:03 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-08-11 14:08:03 +0200 |
commit | 67a3752e176790e82a48706236f889cab4f8913d (patch) | |
tree | 113251396fc2569d1db2c2e6fcadb30289b3aa96 /identity/identity_stub.go | |
parent | a0dfc202117e31e01d2d6ec701a41292df35d35d (diff) | |
download | git-bug-67a3752e176790e82a48706236f889cab4f8913d.tar.gz |
bug,entity: use a dedicated type to store IDs
Diffstat (limited to 'identity/identity_stub.go')
-rw-r--r-- | identity/identity_stub.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/identity/identity_stub.go b/identity/identity_stub.go index a2cee0ad..be52ffc0 100644 --- a/identity/identity_stub.go +++ b/identity/identity_stub.go @@ -3,6 +3,7 @@ package identity import ( "encoding/json" + "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/repository" "github.com/MichaelMure/git-bug/util/lamport" "github.com/MichaelMure/git-bug/util/timestamp" @@ -16,13 +17,13 @@ var _ Interface = &IdentityStub{} // When this JSON is deserialized, an IdentityStub is returned instead, to be replaced // later by the proper Identity, loaded from the Repo. type IdentityStub struct { - id string + id entity.Id } func (i *IdentityStub) MarshalJSON() ([]byte, error) { // TODO: add a type marker return json.Marshal(struct { - Id string `json:"id"` + Id entity.Id `json:"id"` }{ Id: i.id, }) @@ -30,7 +31,7 @@ func (i *IdentityStub) MarshalJSON() ([]byte, error) { func (i *IdentityStub) UnmarshalJSON(data []byte) error { aux := struct { - Id string `json:"id"` + Id entity.Id `json:"id"` }{} if err := json.Unmarshal(data, &aux); err != nil { @@ -43,15 +44,10 @@ func (i *IdentityStub) UnmarshalJSON(data []byte) error { } // Id return the Identity identifier -func (i *IdentityStub) Id() string { +func (i *IdentityStub) Id() entity.Id { return i.id } -// HumanId return the Identity identifier truncated for human consumption -func (i *IdentityStub) HumanId() string { - return FormatHumanID(i.Id()) -} - func (IdentityStub) Name() string { panic("identities needs to be properly loaded with identity.ReadLocal()") } |