aboutsummaryrefslogtreecommitdiff
path: root/pkg/service/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/service/git.go')
-rw-r--r--pkg/service/git.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 9bf11f4..f886785 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -89,6 +89,38 @@ func (g *GitService) ListCommits(name, ref string) ([]*object.Commit, error) {
return repo.Commits()
}
+func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) {
+ // TODO: handle nil
+ r := g.configRepo.GetByName(name)
+
+ repo, err := git.OpenRepository(r.Path)
+ if err != nil {
+ return nil, err
+ }
+ err = repo.SetRef(ref)
+ if err != nil {
+ return nil, err
+ }
+
+ return repo.Tree(path)
+}
+
+func (g *GitService) GetFileContent(name, ref, path string) (string, error) {
+ // TODO: handle nil
+ r := g.configRepo.GetByName(name)
+
+ repo, err := git.OpenRepository(r.Path)
+ if err != nil {
+ return "", err
+ }
+ err = repo.SetRef(ref)
+ if err != nil {
+ return "", err
+ }
+
+ return repo.FileContent(path)
+}
+
func (g *GitService) ListTags(name string) ([]*object.Tag, error) {
// TODO: handle nil
r := g.configRepo.GetByName(name)