diff options
author | Michael Muré <batolettre@gmail.com> | 2022-08-01 17:16:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 17:16:45 +0200 |
commit | cd52872475f1b39f3fb6546606c1e78afb6c08e3 (patch) | |
tree | 9f04b1e1ee362e210e74aaa324d950058ed14bf2 /bug/bug.go | |
parent | 2ade8fb1d570ddcb4aedc9386af46d208b129daa (diff) | |
parent | 56966fec5562c3a0e23340d0fbe754626c3beb64 (diff) | |
download | git-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.go | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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 { |