aboutsummaryrefslogtreecommitdiff
path: root/pkg/service
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-09 19:35:34 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-09 19:35:34 +0200
commit02614b3781f6acdfc6df0e7b07d856b2779c4ac7 (patch)
treef23518fcf263be3236265852ba338c4fec137b41 /pkg/service
parentb1ad6e98445cf7dafa6fec1e2e769051fe7cb748 (diff)
downloadcerrado-02614b3781f6acdfc6df0e7b07d856b2779c4ac7.tar.gz
cerrado-02614b3781f6acdfc6df0e7b07d856b2779c4ac7.tar.bz2
cerrado-02614b3781f6acdfc6df0e7b07d856b2779c4ac7.zip
feat: Per repository configuration
Diffstat (limited to 'pkg/service')
-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