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	// Email return the last version of the email
18	Email() string
19	// Login return the last version of the login
20	Login() string
21	// AvatarUrl return the last version of the Avatar URL
22	AvatarUrl() string
23	// Keys return the last version of the valid keys
24	Keys() []Key
25
26	// ValidKeysAtTime return the set of keys valid at a given lamport time
27	ValidKeysAtTime(time lamport.Time) []Key
28
29	// DisplayName return a non-empty string to display, representing the
30	// identity, based on the non-empty values.
31	DisplayName() string
32
33	// Validate check if the Identity data is valid
34	Validate() error
35
36	// Write the identity into the Repository. In particular, this ensure that
37	// the Id is properly set.
38	Commit(repo repository.ClockedRepo) error
39
40	// If needed, write the identity into the Repository. In particular, this
41	// ensure that the Id is properly set.
42	CommitAsNeeded(repo repository.ClockedRepo) error
43
44	// IsProtected return true if the chain of git commits started to be signed.
45	// If that's the case, only signed commit with a valid key for this identity can be added.
46	IsProtected() bool
47}