interface.go

 1package identity
 2
 3import (
 4	"github.com/MichaelMure/git-bug/repository"
 5	"github.com/MichaelMure/git-bug/util/lamport"
 6	"github.com/MichaelMure/git-bug/util/timestamp"
 7)
 8
 9type Interface interface {
10	// Id return the Identity identifier
11	Id() string
12
13	// HumanId return the Identity identifier truncated for human consumption
14	HumanId() string
15
16	// Name return the last version of the name
17	Name() string
18
19	// Email return the last version of the email
20	Email() string
21
22	// Login return the last version of the login
23	Login() string
24
25	// AvatarUrl return the last version of the Avatar URL
26	AvatarUrl() string
27
28	// Keys return the last version of the valid keys
29	Keys() []Key
30
31	// ValidKeysAtTime return the set of keys valid at a given lamport time
32	ValidKeysAtTime(time lamport.Time) []Key
33
34	// DisplayName return a non-empty string to display, representing the
35	// identity, based on the non-empty values.
36	DisplayName() string
37
38	// Validate check if the Identity data is valid
39	Validate() error
40
41	// Write the identity into the Repository. In particular, this ensure that
42	// the Id is properly set.
43	Commit(repo repository.ClockedRepo) error
44
45	// If needed, write the identity into the Repository. In particular, this
46	// ensure that the Id is properly set.
47	CommitAsNeeded(repo repository.ClockedRepo) error
48
49	// IsProtected return true if the chain of git commits started to be signed.
50	// If that's the case, only signed commit with a valid key for this identity can be added.
51	IsProtected() bool
52
53	// LastModificationLamportTime return the Lamport time at which the last version of the identity became valid.
54	LastModificationLamport() lamport.Time
55
56	// LastModification return the timestamp at which the last version of the identity became valid.
57	LastModification() timestamp.Timestamp
58}