aboutsummaryrefslogtreecommitdiff
path: root/pkg/service
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-06-07 23:02:54 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2024-06-07 23:02:54 +0200
commite9098e00fb6339b759df5b0df2e086cef8a7ce83 (patch)
tree97ada52833cf152cf347f418e24ccb5bc05fd5e4 /pkg/service
parentc7a8aa113a914e70e027fea93265c7232b865b5e (diff)
downloadcerrado-e9098e00fb6339b759df5b0df2e086cef8a7ce83.tar.gz
cerrado-e9098e00fb6339b759df5b0df2e086cef8a7ce83.tar.bz2
cerrado-e9098e00fb6339b759df5b0df2e086cef8a7ce83.zip
feat: Rework some pages
Diffstat (limited to 'pkg/service')
-rw-r--r--pkg/service/git.go36
1 files changed, 23 insertions, 13 deletions
diff --git a/pkg/service/git.go b/pkg/service/git.go
index f886785..31a1cbb 100644
--- a/pkg/service/git.go
+++ b/pkg/service/git.go
@@ -1,21 +1,24 @@
package service
import (
+ "log/slog"
+ "os"
"path"
"git.gabrielgio.me/cerrado/pkg/config"
"git.gabrielgio.me/cerrado/pkg/git"
+ "git.gabrielgio.me/cerrado/pkg/u"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
)
type (
Repository struct {
- Name string
- Title string
- LastCommitMessage string
- LastCommitDate string
- Ref string
+ Name string
+ Title string
+ Description string
+ LastCommitDate string
+ Ref string
}
GitService struct {
@@ -46,9 +49,6 @@ func (g *GitService) ListRepositories() ([]*Repository, error) {
if err != nil {
return nil, err
}
- if err != nil {
- return nil, err
- }
obj, err := repo.LastCommit()
if err != nil {
@@ -60,13 +60,23 @@ func (g *GitService) ListRepositories() ([]*Repository, error) {
return nil, err
}
+ d := path.Join(r.Path, "description")
+ description := ""
+ if u.FileExist(d) {
+ if b, err := os.ReadFile(d); err == nil {
+ description = string(b)
+ } else {
+ slog.Error("Error loading description file", "err", err)
+ }
+ }
+
baseName := path.Base(r.Path)
repos[i] = &Repository{
- Name: baseName,
- Title: baseName,
- LastCommitMessage: obj.Message,
- LastCommitDate: obj.Author.When.Format(timeFormat),
- Ref: head.Name().Short(),
+ Name: baseName,
+ Title: baseName,
+ Description: description,
+ LastCommitDate: obj.Author.When.Format(timeFormat),
+ Ref: head.Name().Short(),
}
}