diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-21 18:18:51 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-21 18:53:37 +0200 |
commit | 82eaceffc1d750832a2a66f206749d2dca968cce (patch) | |
tree | 1431c8f1fd9baa689b850da7f104d12c20b1d8a7 /bug | |
parent | 6a575fbf483e2b28821908f67e87637d9e5cea75 (diff) | |
download | git-bug-82eaceffc1d750832a2a66f206749d2dca968cce.tar.gz |
repo: split the Repo interface to avoid abstraction leak in RepoCache
Diffstat (limited to 'bug')
-rw-r--r-- | bug/bug.go | 16 | ||||
-rw-r--r-- | bug/bug_actions.go | 4 | ||||
-rw-r--r-- | bug/interface.go | 2 | ||||
-rw-r--r-- | bug/with_snapshot.go | 2 |
4 files changed, 12 insertions, 12 deletions
@@ -64,7 +64,7 @@ func NewBug() *Bug { } // FindLocalBug find an existing Bug matching a prefix -func FindLocalBug(repo repository.Repo, prefix string) (*Bug, error) { +func FindLocalBug(repo repository.ClockedRepo, prefix string) (*Bug, error) { ids, err := ListLocalIds(repo) if err != nil { @@ -92,19 +92,19 @@ func FindLocalBug(repo repository.Repo, prefix string) (*Bug, error) { } // ReadLocalBug will read a local bug from its hash -func ReadLocalBug(repo repository.Repo, id string) (*Bug, error) { +func ReadLocalBug(repo repository.ClockedRepo, id string) (*Bug, error) { ref := bugsRefPattern + id return readBug(repo, ref) } // ReadRemoteBug will read a remote bug from its hash -func ReadRemoteBug(repo repository.Repo, remote string, id string) (*Bug, error) { +func ReadRemoteBug(repo repository.ClockedRepo, remote string, id string) (*Bug, error) { ref := fmt.Sprintf(bugsRemoteRefPattern, remote) + id return readBug(repo, ref) } // readBug will read and parse a Bug from git -func readBug(repo repository.Repo, ref string) (*Bug, error) { +func readBug(repo repository.ClockedRepo, ref string) (*Bug, error) { hashes, err := repo.ListCommits(ref) // TODO: this is not perfect, it might be a command invoke error @@ -218,18 +218,18 @@ type StreamedBug struct { } // ReadAllLocalBugs read and parse all local bugs -func ReadAllLocalBugs(repo repository.Repo) <-chan StreamedBug { +func ReadAllLocalBugs(repo repository.ClockedRepo) <-chan StreamedBug { return readAllBugs(repo, bugsRefPattern) } // ReadAllRemoteBugs read and parse all remote bugs for a given remote -func ReadAllRemoteBugs(repo repository.Repo, remote string) <-chan StreamedBug { +func ReadAllRemoteBugs(repo repository.ClockedRepo, remote string) <-chan StreamedBug { refPrefix := fmt.Sprintf(bugsRemoteRefPattern, remote) return readAllBugs(repo, refPrefix) } // Read and parse all available bug with a given ref prefix -func readAllBugs(repo repository.Repo, refPrefix string) <-chan StreamedBug { +func readAllBugs(repo repository.ClockedRepo, refPrefix string) <-chan StreamedBug { out := make(chan StreamedBug) go func() { @@ -331,7 +331,7 @@ func (bug *Bug) HasPendingOp() bool { } // Commit write the staging area in Git and move the operations to the packs -func (bug *Bug) Commit(repo repository.Repo) error { +func (bug *Bug) Commit(repo repository.ClockedRepo) error { if bug.staging.IsEmpty() { return fmt.Errorf("can't commit a bug with no pending operation") } diff --git a/bug/bug_actions.go b/bug/bug_actions.go index 8be4420f..487ba25e 100644 --- a/bug/bug_actions.go +++ b/bug/bug_actions.go @@ -25,7 +25,7 @@ func Push(repo repository.Repo, remote string) (string, error) { // Pull will do a Fetch + MergeAll // This function won't give details on the underlying process. If you need more // use Fetch and MergeAll separately. -func Pull(repo repository.Repo, remote string) error { +func Pull(repo repository.ClockedRepo, remote string) error { _, err := Fetch(repo, remote) if err != nil { return err @@ -41,7 +41,7 @@ func Pull(repo repository.Repo, remote string) error { } // MergeAll will merge all the available remote bug -func MergeAll(repo repository.Repo, remote string) <-chan MergeResult { +func MergeAll(repo repository.ClockedRepo, remote string) <-chan MergeResult { out := make(chan MergeResult) go func() { diff --git a/bug/interface.go b/bug/interface.go index 72dee61c..186c26fc 100644 --- a/bug/interface.go +++ b/bug/interface.go @@ -22,7 +22,7 @@ type Interface interface { HasPendingOp() bool // Commit write the staging area in Git and move the operations to the packs - Commit(repo repository.Repo) error + Commit(repo repository.ClockedRepo) error // Merge a different version of the same bug by rebasing operations of this bug // that are not present in the other on top of the chain of operations of the diff --git a/bug/with_snapshot.go b/bug/with_snapshot.go index a004324b..48274ed5 100644 --- a/bug/with_snapshot.go +++ b/bug/with_snapshot.go @@ -34,7 +34,7 @@ func (b *WithSnapshot) Append(op Operation) { } // Commit intercept Bug.Commit() to update the snapshot efficiently -func (b *WithSnapshot) Commit(repo repository.Repo) error { +func (b *WithSnapshot) Commit(repo repository.ClockedRepo) error { err := b.Bug.Commit(repo) if err != nil { |