1package bug
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 Bug identifier
10 Id() string
11
12 // HumanId return the Bug identifier truncated for human consumption
13 HumanId() string
14
15 // IsValid check if the Bug data is valid
16 IsValid() bool
17
18 // Append an operation into the staging area, to be committed later
19 Append(op Operation)
20
21 // Append an operation into the staging area, to be committed later
22 HasPendingOp() bool
23
24 // Commit write the staging area in Git and move the operations to the packs
25 Commit(repo repository.Repo) error
26
27 // Merge a different version of the same bug by rebasing operations of this bug
28 // that are not present in the other on top of the chain of operations of the
29 // other version.
30 Merge(repo repository.Repo, other Interface) (bool, error)
31
32 // Lookup for the very first operation of the bug.
33 // For a valid Bug, this operation should be a CreateOp
34 FirstOp() Operation
35
36 // Lookup for the very last operation of the bug.
37 // For a valid Bug, should never be nil
38 LastOp() Operation
39
40 // Compile a bug in a easily usable snapshot
41 Compile() Snapshot
42
43 // CreateLamportTime return the Lamport time of creation
44 CreateLamportTime() lamport.Time
45
46 // EditLamportTime return the Lamport time of the last edit
47 EditLamportTime() lamport.Time
48}
49
50func bugFromInterface(bug Interface) *Bug {
51 switch bug.(type) {
52 case *Bug:
53 return bug.(*Bug)
54 case *WithSnapshot:
55 return bug.(*WithSnapshot).Bug
56 default:
57 panic("missing type case")
58 }
59}