diff --git a/pkg/config/config.go b/pkg/config/config.go
index 3759b7cc65b14ec93b21b2e862e20b57248ca111..fd198086bb679225c6cc743d9df9eb2c332d0c53 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -14,9 +14,9 @@ "git.sr.ht/~emersion/go-scfg"
)
var (
- ScanPathErr = errors.New("Scan path does not exist")
- RepoPathErr = errors.New("Repository path does not exist")
- InvalidPropertyErr = errors.New("Invalid property")
+ ErrScanPath = errors.New("Scan path does not exist")
+ ErrRepoPath = errors.New("Repository path does not exist")
+ ErrInvalidProperty = errors.New("Invalid property")
)
type (
@@ -113,7 +113,7 @@ // expandOnScanPath scans the scanPath for folders taking them as repositories
// and applying them default configuration.
func (c *ConfigurationRepository) expandOnScanPath(scanPath string, public bool) error {
if !u.FileExist(scanPath) {
- return ScanPathErr
+ return ErrScanPath
}
entries, err := os.ReadDir(scanPath)
@@ -185,7 +185,7 @@ for _, r := range blocks {
if len(r.Params) != 1 {
return fmt.Errorf(
"Invlid number of params for repository: %w",
- InvalidPropertyErr,
+ ErrInvalidProperty,
)
}
@@ -198,7 +198,7 @@ if len(d.Params) != 1 {
return fmt.Errorf(
"Invlid number of params for %s: %w",
d.Name,
- InvalidPropertyErr,
+ ErrInvalidProperty,
)
}
diff --git a/pkg/ext/compression.go b/pkg/ext/compression.go
index 9e933ef22eb9cfc94962fe018fff50503e11db6e..6c7a219401a031a9bf275adee9b842e4459e978f 100644
--- a/pkg/ext/compression.go
+++ b/pkg/ext/compression.go
@@ -16,7 +16,7 @@ "github.com/klauspost/compress/zstd"
)
var (
- invalidParamErr = errors.New("Invalid weighted param")
+ errInvalidParam = errors.New("Invalid weighted param")
)
type CompressionResponseWriter struct {
@@ -135,7 +135,7 @@
func getWeighedValue(part string) (float64, error) {
ps := strings.SplitN(part, "=", 2)
if len(ps) != 2 {
- return 0, invalidParamErr
+ return 0, errInvalidParam
}
if name := strings.TrimSpace(ps[0]); name == "q" {
w, err := strconv.ParseFloat(ps[1], 64)
@@ -145,5 +145,5 @@ }
return w, nil
}
- return 0, invalidParamErr
+ return 0, errInvalidParam
}
diff --git a/pkg/ext/router.go b/pkg/ext/router.go
index 5d22814e9d53c5a65f4f72c6cdf67be9f929bcbb..96da1c9399992e589bbd4fefdb0bfc78b5e59b80 100644
--- a/pkg/ext/router.go
+++ b/pkg/ext/router.go
@@ -34,7 +34,7 @@
func wrapError(next ErrorRequestHandler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if err := next(w, r); err != nil {
- if errors.Is(err, service.RepositoryNotFoundErr) {
+ if errors.Is(err, service.ErrRepositoryNotFound) {
NotFound(w)
} else {
InternalServerError(w, err)
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 8e25261c1a9c931c0c953960ad1215855f648274..1d212043bc292f173d2e44ccb451871a4469f99e 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -31,7 +31,7 @@ }
)
var (
- RepositoryNotFoundErr = errors.New("Repository not found")
+ ErrRepositoryNotFound = errors.New("Repository not found")
)
// TODO: make it configurable
@@ -79,7 +79,7 @@
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) 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) 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) 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) 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) 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 @@ if err != nil {
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) 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) 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)
diff --git a/pkg/worker/http.go b/pkg/worker/http.go
index 1559ba2eae04e2da705285126dca07f636498a7b..55defd7a2e25ca93f1f4813b57b4ccf0c1dc6950 100644
--- a/pkg/worker/http.go
+++ b/pkg/worker/http.go
@@ -10,7 +10,7 @@ "net/url"
)
var (
- UnsupportedSchemeErr = errors.New("Ivalid schema, only tcp and unix supported")
+ ErrUnsupportedScheme = errors.New("Ivalid schema, only tcp and unix supported")
)
type ServerTask struct {
@@ -72,6 +72,6 @@ return nil, err
}
return net.Listen(u.Scheme, host)
default:
- return nil, UnsupportedSchemeErr
+ return nil, ErrUnsupportedScheme
}
}