aboutsummaryrefslogtreecommitdiffstats
path: root/tree.go
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2016-01-21 11:39:24 +0100
committerAlberto Cortés <alberto@sourced.tech>2016-01-21 11:39:24 +0100
commit5ec2de7f1a563bee521332568df591ef63623232 (patch)
treec1067a2175af73e8fba349128a860dfeb936abff /tree.go
parent07e4c4368921f73048578f22a14a1c671ec3ba46 (diff)
downloadgo-git-5ec2de7f1a563bee521332568df591ef63623232.tar.gz
Readability improvements
Diffstat (limited to 'tree.go')
-rw-r--r--tree.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/tree.go b/tree.go
index 232bfc2..523baac 100644
--- a/tree.go
+++ b/tree.go
@@ -31,8 +31,10 @@ type TreeEntry struct {
// New errors defined by this package.
var ErrFileNotFound = errors.New("file not found")
+// File returns the hash of the file identified by the `path` argument.
+// The path is interpreted as relative to the tree receiver.
func (t *Tree) File(path string) (*File, error) {
- hash, err := t.hashOf(path)
+ hash, err := t.findHash(path)
if err != nil {
return nil, ErrFileNotFound
}
@@ -52,7 +54,7 @@ func (t *Tree) File(path string) (*File, error) {
return &File{Name: path, Reader: blob.Reader(), Hash: *hash}, nil
}
-func (t *Tree) hashOf(path string) (*core.Hash, error) {
+func (t *Tree) findHash(path string) (*core.Hash, error) {
pathParts := strings.Split(path, "/")
var tree *Tree