summaryrefslogtreecommitdiffstats
path: root/hugolib/gitinfo.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-12-30 09:20:58 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-01-04 18:01:26 +0100
commite402d91ee199afcace8ae75da6c3587bb8089ace (patch)
treea0f51de9707ed03aa1a3d7a9195fd9d0fceab108 /hugolib/gitinfo.go
parent3c51625c7152abca7e035fae15fc6807ca21cc86 (diff)
Misc doc, code refactoring to improve documentation
Diffstat (limited to 'hugolib/gitinfo.go')
-rw-r--r--hugolib/gitinfo.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/hugolib/gitinfo.go b/hugolib/gitinfo.go
index 17717ed52..d051b10bc 100644
--- a/hugolib/gitinfo.go
+++ b/hugolib/gitinfo.go
@@ -20,6 +20,7 @@ import (
"github.com/bep/gitmap"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/resources/page"
+ "github.com/gohugoio/hugo/source"
)
type gitInfo struct {
@@ -27,11 +28,14 @@ type gitInfo struct {
repo *gitmap.GitRepo
}
-func (g *gitInfo) forPage(p page.Page) *gitmap.GitInfo {
+func (g *gitInfo) forPage(p page.Page) source.GitInfo {
name := strings.TrimPrefix(filepath.ToSlash(p.File().Filename()), g.contentDir)
name = strings.TrimPrefix(name, "/")
-
- return g.repo.Files[name]
+ gi, found := g.repo.Files[name]
+ if !found {
+ return source.GitInfo{}
+ }
+ return source.NewGitInfo(*gi)
}
func newGitInfo(cfg config.Provider) (*gitInfo, error) {