1package board
2
3import (
4 "github.com/MichaelMure/git-bug/entities/identity"
5 "github.com/MichaelMure/git-bug/entity"
6 "github.com/MichaelMure/git-bug/entity/dag"
7 "github.com/MichaelMure/git-bug/repository"
8)
9
10// Fetch retrieve updates from a remote
11// This does not change the local board state
12func Fetch(repo repository.Repo, remote string) (string, error) {
13 return dag.Fetch(def, repo, remote)
14}
15
16// Push update a remote with the local changes
17func Push(repo repository.Repo, remote string) (string, error) {
18 return dag.Push(def, repo, remote)
19}
20
21// Pull will do a Fetch + MergeAll
22// This function will return an error if a merge fail
23// Note: an author is necessary for the case where a merge commit is created, as this commit will
24// have an author and may be signed if a signing key is available.
25func Pull(repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, mergeAuthor identity.Interface) error {
26 return dag.Pull(def, repo, resolvers, remote, mergeAuthor)
27}
28
29// MergeAll will merge all the available remote board
30// Note: an author is necessary for the case where a merge commit is created, as this commit will
31// have an author and may be signed if a signing key is available.
32func MergeAll(repo repository.ClockedRepo, resolvers entity.Resolvers, remote string, mergeAuthor identity.Interface) <-chan entity.MergeResult {
33 out := make(chan entity.MergeResult)
34
35 go func() {
36 defer close(out)
37
38 results := dag.MergeAll(def, repo, resolvers, remote, mergeAuthor)
39
40 // wrap the dag.Entity into a complete Bug
41 for result := range results {
42 result := result
43 if result.Entity != nil {
44 result.Entity = &Board{
45 Entity: result.Entity.(*dag.Entity),
46 }
47 }
48 out <- result
49 }
50 }()
51
52 return out
53}
54
55// Remove will remove a local bug from its entity.Id
56func Remove(repo repository.ClockedRepo, id entity.Id) error {
57 return dag.Remove(def, repo, id)
58}