1package dag
 2
 3import (
 4	"github.com/git-bug/git-bug/entity"
 5	"github.com/git-bug/git-bug/repository"
 6	"github.com/git-bug/git-bug/util/lamport"
 7)
 8
 9// Interface define the extended interface of a dag.Entity
10type Interface[SnapT Snapshot, OpT Operation] interface {
11	entity.Interface
12
13	// Validate checks if the Entity data is valid
14	Validate() error
15
16	// Append an operation into the staging area, to be committed later
17	Append(op OpT)
18
19	// Operations returns the ordered operations
20	Operations() []OpT
21
22	// NeedCommit indicates that the in-memory state changed and need to be committed in the repository
23	NeedCommit() bool
24
25	// Commit writes the staging area in Git and move the operations to the packs
26	Commit(repo repository.ClockedRepo) error
27
28	// CommitAsNeeded execute a Commit only if necessary. This function is useful to avoid getting an error if the Entity
29	// is already in sync with the repository.
30	CommitAsNeeded(repo repository.ClockedRepo) error
31
32	// FirstOp lookup for the very first operation of the Entity.
33	FirstOp() OpT
34
35	// LastOp lookup for the very last operation of the Entity.
36	// For a valid Entity, should never be nil
37	LastOp() OpT
38
39	// Compile an Entity in an easily usable snapshot
40	Compile() SnapT
41
42	// CreateLamportTime return the Lamport time of creation
43	CreateLamportTime() lamport.Time
44
45	// EditLamportTime return the Lamport time of the last edit
46	EditLamportTime() lamport.Time
47}