diff options
Diffstat (limited to 'entities/bug')
-rw-r--r-- | entities/bug/bug.go | 8 | ||||
-rw-r--r-- | entities/bug/bug_actions.go | 22 | ||||
-rw-r--r-- | entities/bug/interface.go | 44 |
3 files changed, 9 insertions, 65 deletions
diff --git a/entities/bug/bug.go b/entities/bug/bug.go index 1140c543..b0f46c0b 100644 --- a/entities/bug/bug.go +++ b/entities/bug/bug.go @@ -29,6 +29,10 @@ var def = dag.Definition{ var ClockLoader = dag.ClockLoader(def) +type Interface interface { + dag.Interface[*Snapshot, Operation] +} + // Bug holds the data of a bug thread, organized in a way close to // how it will be persisted inside Git. This is the data structure // used to merge two different version of the same Bug. @@ -119,7 +123,7 @@ func (bug *Bug) Validate() error { } // Check that there is no more CreateOp op - for i, op := range bug.Operations() { + for i, op := range bug.Entity.Operations() { if i == 0 { continue } @@ -146,7 +150,7 @@ func (bug *Bug) Operations() []Operation { return result } -// Compile a bug in a easily usable snapshot +// Compile a bug in an easily usable snapshot func (bug *Bug) Compile() *Snapshot { snap := &Snapshot{ id: bug.Id(), diff --git a/entities/bug/bug_actions.go b/entities/bug/bug_actions.go index 864c2052..c25b9243 100644 --- a/entities/bug/bug_actions.go +++ b/entities/bug/bug_actions.go @@ -1,8 +1,6 @@ package bug import ( - "github.com/pkg/errors" - "github.com/MichaelMure/git-bug/entities/identity" "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/entity/dag" @@ -25,21 +23,7 @@ func Push(repo repository.Repo, remote string) (string, error) { // Note: an author is necessary for the case where a merge commit is created, as this commit will // have an author and may be signed if a signing key is available. func Pull(repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, mergeAuthor identity.Interface) error { - _, err := Fetch(repo, remote) - if err != nil { - return err - } - - for merge := range MergeAll(repo, resolvers, remote, mergeAuthor) { - if merge.Err != nil { - return merge.Err - } - if merge.Status == entity.MergeStatusInvalid { - return errors.Errorf("merge failure: %s", merge.Reason) - } - } - - return nil + return dag.Pull(def, repo, resolvers, remote, mergeAuthor) } // MergeAll will merge all the available remote bug @@ -68,7 +52,7 @@ func MergeAll(repo repository.ClockedRepo, resolvers entity.Resolvers, remote st return out } -// RemoveBug will remove a local bug from its entity.Id -func RemoveBug(repo repository.ClockedRepo, id entity.Id) error { +// Remove will remove a local bug from its entity.Id +func Remove(repo repository.ClockedRepo, id entity.Id) error { return dag.Remove(def, repo, id) } diff --git a/entities/bug/interface.go b/entities/bug/interface.go deleted file mode 100644 index 2ae31fd1..00000000 --- a/entities/bug/interface.go +++ /dev/null @@ -1,44 +0,0 @@ -package bug - -import ( - "github.com/MichaelMure/git-bug/entity" - "github.com/MichaelMure/git-bug/repository" - "github.com/MichaelMure/git-bug/util/lamport" -) - -type Interface interface { - // Id returns the Bug identifier - Id() entity.Id - - // Validate checks if the Bug data is valid - Validate() error - - // Append an operation into the staging area, to be committed later - Append(op Operation) - - // Operations returns the ordered operations - Operations() []Operation - - // NeedCommit indicates that the in-memory state changed and need to be commit in the repository - NeedCommit() bool - - // Commit writes the staging area in Git and move the operations to the packs - Commit(repo repository.ClockedRepo) error - - // FirstOp lookup for the very first operation of the bug. - // For a valid Bug, this operation should be a CreateOp - FirstOp() Operation - - // LastOp lookup for the very last operation of the bug. - // For a valid Bug, should never be nil - LastOp() Operation - - // Compile a bug in an easily usable snapshot - Compile() *Snapshot - - // CreateLamportTime return the Lamport time of creation - CreateLamportTime() lamport.Time - - // EditLamportTime return the Lamport time of the last edit - EditLamportTime() lamport.Time -} |