diff options
author | Alberto Cortés <alberto@sourced.tech> | 2016-01-21 11:39:24 +0100 |
---|---|---|
committer | Alberto Cortés <alberto@sourced.tech> | 2016-01-21 11:39:24 +0100 |
commit | 5ec2de7f1a563bee521332568df591ef63623232 (patch) | |
tree | c1067a2175af73e8fba349128a860dfeb936abff /tree.go | |
parent | 07e4c4368921f73048578f22a14a1c671ec3ba46 (diff) | |
download | go-git-5ec2de7f1a563bee521332568df591ef63623232.tar.gz |
Readability improvements
Diffstat (limited to 'tree.go')
-rw-r--r-- | tree.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 |