diff options
Diffstat (limited to 'pkg/service/git.go')
-rw-r--r-- | pkg/service/git.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go index 8e25261..1d21204 100644 --- a/pkg/service/git.go +++ b/pkg/service/git.go @@ -31,7 +31,7 @@ type ( ) var ( - RepositoryNotFoundErr = errors.New("Repository not found") + ErrRepositoryNotFound = errors.New("Repository not found") ) // TODO: make it configurable @@ -79,7 +79,7 @@ func (g *GitService) ListRepositories() ([]*Repository, error) { func (g *GitService) ListCommits(name, ref string, count int) ([]*object.Commit, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -97,7 +97,7 @@ func (g *GitService) ListCommits(name, ref string, count int) ([]*object.Commit, func (g *GitService) WriteTarGZip(w io.Writer, name, ref string, prefix string) error { r := g.configRepo.GetByName(name) if r == nil { - return RepositoryNotFoundErr + return ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -124,7 +124,7 @@ func (g *GitService) WriteTarGZip(w io.Writer, name, ref string, prefix string) func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -142,7 +142,7 @@ func (g *GitService) GetTree(name, ref, path string) (*object.Tree, error) { func (g *GitService) IsBinary(name, ref, path string) (bool, error) { r := g.configRepo.GetByName(name) if r == nil { - return false, RepositoryNotFoundErr + return false, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -160,7 +160,7 @@ func (g *GitService) IsBinary(name, ref, path string) (bool, error) { func (g *GitService) GetFileContent(name, ref, path string) ([]byte, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -178,7 +178,7 @@ func (g *GitService) GetFileContent(name, ref, path string) ([]byte, error) { func (g *GitService) GetAbout(name string) ([]byte, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -190,13 +190,18 @@ func (g *GitService) GetAbout(name string) ([]byte, error) { return nil, err } - return repo.FileContent(r.About) + file, err := repo.FileContent(r.About) + if err != nil { + return nil, err + } + + return file, nil } func (g *GitService) ListTags(name string) ([]*plumbing.Reference, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -209,7 +214,7 @@ func (g *GitService) ListTags(name string) ([]*plumbing.Reference, error) { func (g *GitService) ListBranches(name string) ([]*plumbing.Reference, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) @@ -222,7 +227,7 @@ func (g *GitService) ListBranches(name string) ([]*plumbing.Reference, error) { func (g *GitService) GetHead(name string) (*plumbing.Reference, error) { r := g.configRepo.GetByName(name) if r == nil { - return nil, RepositoryNotFoundErr + return nil, ErrRepositoryNotFound } repo, err := git.OpenRepository(r.Path) |