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.go26
1 files changed, 15 insertions, 11 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index 94ca75e..2b1fe25 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -3,44 +3,48 @@ package service
import (
"path"
+ "git.gabrielgio.me/cerrado/pkg/config"
"git.gabrielgio.me/cerrado/pkg/git"
)
type (
- GitService struct {
- server *git.GitServerRepository
- }
Repository struct {
Name string
Title string
LastCommitMessage string
LastCommitDate string
}
+
+ GitService struct {
+ configRepo configurationRepository
+ }
+
+ configurationRepository interface {
+ List() []*config.GitRepositoryConfiguration
+ }
)
// TODO: make it configurable
const timeFormat = "2006.01.02 15:04:05"
-func NewGitService(server *git.GitServerRepository) *GitService {
+func NewGitService(configRepo configurationRepository) *GitService {
return &GitService{
- server: server,
+ configRepo: configRepo,
}
}
func (g *GitService) ListRepositories() ([]*Repository, error) {
- rs, err := g.server.List()
- if err != nil {
- return nil, err
- }
+ rs := g.configRepo.List()
repos := make([]*Repository, len(rs))
for i, r := range rs {
- obj, err := r.LastCommit()
+ repo := git.NewGitRepository(r.Path)
+ obj, err := repo.LastCommit()
if err != nil {
return nil, err
}
- baseName := path.Base(r.Path())
+ baseName := path.Base(r.Path)
repos[i] = &Repository{
Name: baseName,
Title: baseName,