interface.go

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