aboutsummaryrefslogtreecommitdiffstats
path: root/cache/repo_cache.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-02 15:37:28 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-02 15:37:28 +0200
commit6ff02ed84254275f2d19569a1a5f14efc1d47f31 (patch)
treec6e685156ee22e6f7aee76190ea6d6c391b3899e /cache/repo_cache.go
parent150b5d489c8573fe9214c11defbeeddedde48e16 (diff)
downloadgit-bug-6ff02ed84254275f2d19569a1a5f14efc1d47f31.tar.gz
add some documentation
Diffstat (limited to 'cache/repo_cache.go')
-rw-r--r--cache/repo_cache.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 3d98806c..3ce2f0c2 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -44,6 +44,8 @@ func NewRepoCache(r repository.Repo) (*RepoCache, error) {
return c, c.writeExcerpts()
}
+// Repository return the underlying repository.
+// If you use this, make sure to never change the repo state.
func (c *RepoCache) Repository() repository.Repo {
return c.repo
}
@@ -205,14 +207,19 @@ func (c *RepoCache) AllBugIds() ([]string, error) {
return bug.ListLocalIds(c.repo)
}
+// ClearAllBugs clear all bugs kept in memory
func (c *RepoCache) ClearAllBugs() {
c.bugs = make(map[string]*BugCache)
}
+// NewBug create a new bug
+// The new bug is written in the repository (commit)
func (c *RepoCache) NewBug(title string, message string) (*BugCache, error) {
return c.NewBugWithFiles(title, message, nil)
}
+// NewBugWithFiles create a new bug with attached files for the message
+// The new bug is written in the repository (commit)
func (c *RepoCache) NewBugWithFiles(title string, message string, files []util.Hash) (*BugCache, error) {
author, err := bug.GetUser(c.repo)
if err != nil {
@@ -235,6 +242,8 @@ func (c *RepoCache) NewBugWithFiles(title string, message string, files []util.H
return cached, nil
}
+// Fetch retrieve update from a remote
+// This does not change the local bugs state
func (c *RepoCache) Fetch(remote string) (string, error) {
return bug.Fetch(c.repo, remote)
}
@@ -243,10 +252,12 @@ func (c *RepoCache) MergeAll(remote string) <-chan bug.MergeResult {
return bug.MergeAll(c.repo, remote)
}
+// Pull does a Fetch and merge the updates into the local bug states
func (c *RepoCache) Pull(remote string, out io.Writer) error {
return bug.Pull(c.repo, out, remote)
}
+// Push update a remote with the local changes
func (c *RepoCache) Push(remote string) (string, error) {
return bug.Push(c.repo, remote)
}
@@ -259,7 +270,6 @@ func repoLockFilePath(repo repository.Repo) string {
// Note: this is a smart function that will cleanup the lock file if the
// corresponding process is not there anymore.
// If no error is returned, the repo is free to edit.
-// @Deprecated
func repoIsAvailable(repo repository.Repo) error {
lockPath := repoLockFilePath(repo)