aboutsummaryrefslogtreecommitdiff
path: root/pkg/service
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/service')
-rw-r--r--pkg/service/git.go34
1 files changed, 26 insertions, 8 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 654d6ac..8e25261 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -139,37 +139,55 @@ func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) {
return repo.Tree(path)
}
-func (g *GitService) GetFileContent(name, ref, path string) (string, error) {
+func (g *GitService) IsBinary(name, ref, path string) (bool, error) {
r := g.configRepo.GetByName(name)
if r == nil {
- return "", RepositoryNotFoundErr
+ return false, RepositoryNotFoundErr
}
repo, err := git.OpenRepository(r.Path)
if err != nil {
- return "", err
+ return false, err
}
err = repo.SetRef(ref)
if err != nil {
- return "", err
+ return false, err
+ }
+
+ return repo.IsBinary(path)
+}
+
+func (g *GitService) GetFileContent(name, ref, path string) ([]byte, error) {
+ r := g.configRepo.GetByName(name)
+ if r == nil {
+ return nil, RepositoryNotFoundErr
+ }
+
+ repo, err := git.OpenRepository(r.Path)
+ if err != nil {
+ return nil, err
+ }
+ err = repo.SetRef(ref)
+ if err != nil {
+ return nil, err
}
return repo.FileContent(path)
}
-func (g *GitService) GetAbout(name string) (string, error) {
+func (g *GitService) GetAbout(name string) ([]byte, error) {
r := g.configRepo.GetByName(name)
if r == nil {
- return "", RepositoryNotFoundErr
+ return nil, RepositoryNotFoundErr
}
repo, err := git.OpenRepository(r.Path)
if err != nil {
- return "", err
+ return nil, err
}
err = repo.SetRef("")
if err != nil {
- return "", err
+ return nil, err
}
return repo.FileContent(r.About)