aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-07-16 10:44:01 +0200
committerGitHub <noreply@github.com>2018-07-16 10:44:01 +0200
commit5b1d5370c36994851da002f76ae7cbd3b7bc9221 (patch)
tree7092f0063e00cdaba30e0df7acdefc3aa6897abe
parent400b083e49c5328776359e0df495f98b01efbf63 (diff)
parentb304997a387a5106321fe87069a6f136d9fbd1f6 (diff)
downloadgo-git-5b1d5370c36994851da002f76ae7cbd3b7bc9221.tar.gz
Merge pull request #885 from jsravn/findentry-return-file-not-found
plumbing: object, return ErrFileNotFound in FindEntry. Fixes #883
-rw-r--r--plumbing/object/tree.go5
-rw-r--r--plumbing/object/tree_test.go6
2 files changed, 8 insertions, 3 deletions
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index 86d19c0..c36a137 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -26,6 +26,7 @@ var (
ErrMaxTreeDepth = errors.New("maximum tree depth exceeded")
ErrFileNotFound = errors.New("file not found")
ErrDirectoryNotFound = errors.New("directory not found")
+ ErrEntryNotFound = errors.New("entry not found")
)
// Tree is basically like a directory - it references a bunch of other trees
@@ -167,8 +168,6 @@ func (t *Tree) dir(baseName string) (*Tree, error) {
return tree, err
}
-var errEntryNotFound = errors.New("entry not found")
-
func (t *Tree) entry(baseName string) (*TreeEntry, error) {
if t.m == nil {
t.buildMap()
@@ -176,7 +175,7 @@ func (t *Tree) entry(baseName string) (*TreeEntry, error) {
entry, ok := t.m[baseName]
if !ok {
- return nil, errEntryNotFound
+ return nil, ErrEntryNotFound
}
return entry, nil
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go
index 3a687dd..59d5d21 100644
--- a/plumbing/object/tree_test.go
+++ b/plumbing/object/tree_test.go
@@ -114,6 +114,12 @@ func (s *TreeSuite) TestFindEntry(c *C) {
c.Assert(e.Name, Equals, "foo.go")
}
+func (s *TreeSuite) TestFindEntryNotFound(c *C) {
+ e, err := s.Tree.FindEntry("not-found")
+ c.Assert(e, IsNil)
+ c.Assert(err, Equals, ErrEntryNotFound)
+}
+
// Overrides returned plumbing.EncodedObject for given hash.
// Otherwise, delegates to actual storer to get real object
type fakeStorer struct {