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.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 94e2adc..7418d97 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -16,7 +16,6 @@ import (
type (
Repository struct {
Name string
- Title string
Description string
LastCommitDate string
Ref string
@@ -48,8 +47,8 @@ func NewGitService(configRepo configurationRepository) *GitService {
func (g *GitService) ListRepositories() ([]*Repository, error) {
rs := g.configRepo.List()
- repos := make([]*Repository, len(rs))
- for i, r := range rs {
+ repos := make([]*Repository, 0, len(rs))
+ for _, r := range rs {
repo, err := git.OpenRepository(r.Path)
if err != nil {
return nil, err
@@ -57,12 +56,14 @@ func (g *GitService) ListRepositories() ([]*Repository, error) {
obj, err := repo.LastCommit()
if err != nil {
- return nil, err
+ slog.Error("Error fetching last commit", "repository", r.Path, "error", err)
+ continue
}
head, err := repo.Head()
if err != nil {
- return nil, err
+ slog.Error("Error fetching head", "repository", r.Path, "error", err)
+ continue
}
d := path.Join(r.Path, "description")
@@ -75,14 +76,12 @@ func (g *GitService) ListRepositories() ([]*Repository, error) {
}
}
- baseName := path.Base(r.Path)
- repos[i] = &Repository{
- Name: baseName,
- Title: baseName,
+ repos = append(repos, &Repository{
+ Name: r.Name,
Description: description,
LastCommitDate: obj.Author.When.Format(timeFormat),
Ref: head.Name().Short(),
- }
+ })
}
return repos, nil