summaryrefslogtreecommitdiffstatshomepage
path: root/bug/bug.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-08-01 17:16:45 +0200
committerGitHub <noreply@github.com>2022-08-01 17:16:45 +0200
commitcd52872475f1b39f3fb6546606c1e78afb6c08e3 (patch)
tree9f04b1e1ee362e210e74aaa324d950058ed14bf2 /bug/bug.go
parent2ade8fb1d570ddcb4aedc9386af46d208b129daa (diff)
parent56966fec5562c3a0e23340d0fbe754626c3beb64 (diff)
downloadgit-bug-cd52872475f1b39f3fb6546606c1e78afb6c08e3.tar.gz
git-bug-cd52872475f1b39f3fb6546606c1e78afb6c08e3.zip
Merge pull request #835 from MichaelMure/op-base
entity/dag: proper base operation for simplified implementation
Diffstat (limited to 'bug/bug.go')
-rw-r--r--bug/bug.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/bug/bug.go b/bug/bug.go
index 48269a91..dce30f76 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -44,11 +44,7 @@ func NewBug() *Bug {
// Read will read a bug from a repository
func Read(repo repository.ClockedRepo, id entity.Id) (*Bug, error) {
- e, err := dag.Read(def, repo, identity.NewSimpleResolver(repo), id)
- if err != nil {
- return nil, err
- }
- return &Bug{Entity: e}, nil
+ return ReadWithResolver(repo, identity.NewSimpleResolver(repo), id)
}
// ReadWithResolver will read a bug from its Id, with a custom identity.Resolver
@@ -144,21 +140,21 @@ func (bug *Bug) Operations() []Operation {
}
// Compile a bug in a easily usable snapshot
-func (bug *Bug) Compile() Snapshot {
- snap := Snapshot{
+func (bug *Bug) Compile() *Snapshot {
+ snap := &Snapshot{
id: bug.Id(),
Status: OpenStatus,
}
for _, op := range bug.Operations() {
- op.Apply(&snap)
+ op.Apply(snap)
snap.Operations = append(snap.Operations, op)
}
return snap
}
-// Lookup for the very first operation of the bug.
+// FirstOp lookup for the very first operation of the bug.
// For a valid Bug, this operation should be a CreateOp
func (bug *Bug) FirstOp() Operation {
if fo := bug.Entity.FirstOp(); fo != nil {
@@ -167,7 +163,7 @@ func (bug *Bug) FirstOp() Operation {
return nil
}
-// Lookup for the very last operation of the bug.
+// LastOp lookup for the very last operation of the bug.
// For a valid Bug, should never be nil
func (bug *Bug) LastOp() Operation {
if lo := bug.Entity.LastOp(); lo != nil {