mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Remove the internal GitInfo type and make Page.GitInf() return a pointer
See #5693
This commit is contained in:
@@ -30,14 +30,14 @@ type gitInfo struct {
|
||||
repo *gitmap.GitRepo
|
||||
}
|
||||
|
||||
func (g *gitInfo) forPage(p page.Page) source.GitInfo {
|
||||
func (g *gitInfo) forPage(p page.Page) *source.GitInfo {
|
||||
name := strings.TrimPrefix(filepath.ToSlash(p.File().Filename()), g.contentDir)
|
||||
name = strings.TrimPrefix(name, "/")
|
||||
gi, found := g.repo.Files[name]
|
||||
if !found {
|
||||
return source.GitInfo{}
|
||||
return nil
|
||||
}
|
||||
return source.NewGitInfo(*gi)
|
||||
return gi
|
||||
}
|
||||
|
||||
func newGitInfo(d *deps.Deps) (*gitInfo, error) {
|
||||
|
@@ -230,13 +230,13 @@ func (h *HugoSites) RegularPages() page.Pages {
|
||||
return v
|
||||
}
|
||||
|
||||
func (h *HugoSites) gitInfoForPage(p page.Page) (source.GitInfo, error) {
|
||||
func (h *HugoSites) gitInfoForPage(p page.Page) (*source.GitInfo, error) {
|
||||
if _, err := h.init.gitInfo.Do(context.Background()); err != nil {
|
||||
return source.GitInfo{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if h.gitInfo == nil {
|
||||
return source.GitInfo{}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return h.gitInfo.forPage(p), nil
|
||||
|
@@ -238,7 +238,7 @@ func (p *pageState) ApplyFilterToHeadings(ctx context.Context, fn func(*tableofc
|
||||
}
|
||||
}
|
||||
|
||||
func (p *pageState) GitInfo() source.GitInfo {
|
||||
func (p *pageState) GitInfo() *source.GitInfo {
|
||||
return p.gitInfo
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ type pageCommon struct {
|
||||
targetPathDescriptor page.TargetPathDescriptor
|
||||
|
||||
// Set if feature enabled and this is in a Git repo.
|
||||
gitInfo source.GitInfo
|
||||
gitInfo *source.GitInfo
|
||||
codeowners []string
|
||||
|
||||
// Positional navigation
|
||||
|
@@ -405,7 +405,7 @@ func (p *pageState) setMetaPostParams() error {
|
||||
}
|
||||
|
||||
var gitAuthorDate time.Time
|
||||
if !p.gitInfo.IsZero() {
|
||||
if p.gitInfo != nil {
|
||||
gitAuthorDate = p.gitInfo.AuthorDate
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user