cache: doc & cleaning

Michael Muré created

Change summary

cache/filter.go     | 6 ++++++
cache/query.go      | 2 +-
cache/query_test.go | 5 +++--
cache/repo_cache.go | 4 ++--
4 files changed, 12 insertions(+), 5 deletions(-)

Detailed changes

cache/filter.go 🔗

@@ -6,8 +6,10 @@ import (
 	"github.com/MichaelMure/git-bug/bug"
 )
 
+// Filter is a functor that match a subset of bugs
 type Filter func(excerpt *BugExcerpt) bool
 
+// StatusFilter return a Filter that match a bug status
 func StatusFilter(query string) (Filter, error) {
 	status, err := bug.StatusFromString(query)
 	if err != nil {
@@ -19,6 +21,7 @@ func StatusFilter(query string) (Filter, error) {
 	}, nil
 }
 
+// AuthorFilter return a Filter that match a bug author
 func AuthorFilter(query string) Filter {
 	cleaned := strings.TrimFunc(query, func(r rune) bool {
 		return r == '"' || r == '\''
@@ -29,6 +32,7 @@ func AuthorFilter(query string) Filter {
 	}
 }
 
+// LabelFilter return a Filter that match a label
 func LabelFilter(label string) Filter {
 	return func(excerpt *BugExcerpt) bool {
 		for _, l := range excerpt.Labels {
@@ -40,12 +44,14 @@ func LabelFilter(label string) Filter {
 	}
 }
 
+// NoLabelFilter return a Filter that match the absence of labels
 func NoLabelFilter() Filter {
 	return func(excerpt *BugExcerpt) bool {
 		return len(excerpt.Labels) == 0
 	}
 }
 
+// Filters is a collection of Filter that implement a complex filter
 type Filters struct {
 	Status    []Filter
 	Author    []Filter

cache/query.go 🔗

@@ -16,7 +16,7 @@ type Query struct {
 //
 // Ex: "status:open author:descartes sort:edit-asc"
 //
-// Supported filter fields and syntax are described in docs/queries.md
+// Supported filter qualifiers and syntax are described in docs/queries.md
 func ParseQuery(query string) (*Query, error) {
 	fields := splitQuery(query)
 

cache/query_test.go 🔗

@@ -3,6 +3,7 @@ package cache
 import "testing"
 
 func TestQueryParse(t *testing.T) {
+
 	var tests = []struct {
 		input string
 		ok    bool
@@ -16,10 +17,10 @@ func TestQueryParse(t *testing.T) {
 		{"status:unknown", false},
 
 		{"author:rene", true},
-		{"author:\"René Descartes\"", true},
+		{`author:"René Descartes"`, true},
 
 		{"label:hello", true},
-		{"label:\"Good first issue\"", true},
+		{`label:"Good first issue"`, true},
 
 		{"sort:edit", true},
 		{"sort:unknown", false},

cache/repo_cache.go 🔗

@@ -387,7 +387,7 @@ func repoIsAvailable(repo repository.Repo) error {
 			return err
 		}
 		if len(buf) == 10 {
-			return fmt.Errorf("The lock file should be < 10 bytes")
+			return fmt.Errorf("the lock file should be < 10 bytes")
 		}
 
 		pid, err := strconv.Atoi(string(buf))
@@ -396,7 +396,7 @@ func repoIsAvailable(repo repository.Repo) error {
 		}
 
 		if util.ProcessIsRunning(pid) {
-			return fmt.Errorf("The repository you want to access is already locked by the process pid %d", pid)
+			return fmt.Errorf("the repository you want to access is already locked by the process pid %d", pid)
 		}
 
 		// The lock file is just laying there after a crash, clean it