aboutsummaryrefslogtreecommitdiff
path: root/pkg/service
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-23 17:47:50 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-23 17:51:05 +0200
commit9e210f61a6259c37cc7938cf353527cf072b3eda (patch)
tree5f2855377262b2e915ebf801502c835d6bcec75b /pkg/service
parentba84c0d82066739adbca468846a2688e02432b6f (diff)
downloadcerrado-9e210f61a6259c37cc7938cf353527cf072b3eda.tar.gz
cerrado-9e210f61a6259c37cc7938cf353527cf072b3eda.tar.bz2
cerrado-9e210f61a6259c37cc7938cf353527cf072b3eda.zip
ref: User correct err naming
Diffstat (limited to 'pkg/service')
-rw-r--r--pkg/service/git.go27
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)