From 02614b3781f6acdfc6df0e7b07d856b2779c4ac7 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 9 Jun 2024 19:35:34 +0200 Subject: feat: Per repository configuration --- pkg/service/git.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'pkg/service/git.go') 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 -- cgit v1.2.3