fix(git): add missing errors

Ayman Bagabas created

Change summary

git/errors.go | 8 +++++++-
git/repo.go   | 5 +++--
git/tree.go   | 8 +++++---
3 files changed, 15 insertions(+), 6 deletions(-)

Detailed changes

git/errors.go 🔗

@@ -1,6 +1,10 @@
 package git
 
-import "errors"
+import (
+	"errors"
+
+	"github.com/gogs/git-module"
+)
 
 var (
 	// ErrFileNotFound is returned when a file is not found.
@@ -9,4 +13,6 @@ var (
 	ErrDirectoryNotFound = errors.New("directory not found")
 	// ErrReferenceNotFound is returned when a reference is not found.
 	ErrReferenceNotFound = errors.New("reference not found")
+	// ErrRevisionNotExist is returned when a revision is not found.
+	ErrRevisionNotExist = git.ErrRevisionNotExist
 )

git/repo.go 🔗

@@ -103,8 +103,9 @@ func (r *Repository) Tree(ref *Reference) (*Tree, error) {
 		return nil, err
 	}
 	return &Tree{
-		Tree: tree,
-		Path: "",
+		Tree:       tree,
+		Path:       "",
+		Repository: r,
 	}, nil
 }
 

git/tree.go 🔗

@@ -14,7 +14,8 @@ import (
 // Tree is a wrapper around git.Tree with helper methods.
 type Tree struct {
 	*git.Tree
-	Path string
+	Path       string
+	Repository *Repository
 }
 
 // TreeEntry is a wrapper around git.TreeEntry with helper methods.
@@ -86,8 +87,9 @@ func (t *Tree) SubTree(path string) (*Tree, error) {
 		return nil, err
 	}
 	return &Tree{
-		Tree: tree,
-		Path: path,
+		Tree:       tree,
+		Path:       path,
+		Repository: t.Repository,
 	}, nil
 }