aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/tree_blob.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/tree_blob.go')
-rw-r--r--modules/git/tree_blob.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/git/tree_blob.go b/modules/git/tree_blob.go
index debc722bc9..f996aba376 100644
--- a/modules/git/tree_blob.go
+++ b/modules/git/tree_blob.go
@@ -44,3 +44,16 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
}
return nil, fmt.Errorf("GetTreeEntryByPath: %v", ErrNotExist)
}
+
+func (t *Tree) GetBlobByPath(rpath string) (*Blob, error) {
+ entry, err := t.GetTreeEntryByPath(rpath)
+ if err != nil {
+ return nil, err
+ }
+
+ if !entry.IsDir() {
+ return entry.Blob(), nil
+ }
+
+ return nil, ErrNotExist
+}