interface.go

 1package bug
 2
 3import (
 4	"github.com/MichaelMure/git-bug/entity"
 5	"github.com/MichaelMure/git-bug/repository"
 6	"github.com/MichaelMure/git-bug/util/lamport"
 7)
 8
 9type Interface interface {
10	// Id return the Bug identifier
11	Id() entity.Id
12
13	// Validate check if the Bug data is valid
14	Validate() error
15
16	// Append an operation into the staging area, to be committed later
17	Append(op Operation)
18
19	// Operations return the ordered operations
20	Operations() []Operation
21
22	// NeedCommit indicate that the in-memory state changed and need to be commit in the repository
23	NeedCommit() bool
24
25	// Commit write the staging area in Git and move the operations to the packs
26	Commit(repo repository.ClockedRepo) error
27
28	// FirstOp lookup for the very first operation of the bug.
29	// For a valid Bug, this operation should be a CreateOp
30	FirstOp() Operation
31
32	// LastOp lookup for the very last operation of the bug.
33	// For a valid Bug, should never be nil
34	LastOp() Operation
35
36	// Compile a bug in a easily usable snapshot
37	Compile() Snapshot
38
39	// CreateLamportTime return the Lamport time of creation
40	CreateLamportTime() lamport.Time
41
42	// EditLamportTime return the Lamport time of the last edit
43	EditLamportTime() lamport.Time
44}