URI: 
       source: Expose Ancestor in GitInfo - hugo - [fork] hugo port for 9front
  HTML git clone git@git.drkhsh.at/hugo.git
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 61e6c730dd2e36ae224d1b1a9cafdea21568591e
   DIR parent e4f6b9eef8ef3c2c68c45466d31ba4e5bc039db6
  HTML Author: Jens Broekens <jens.broekens@protonmail.com>
       Date:   Wed, 26 Mar 2025 20:12:48 +0100
       
       source: Expose Ancestor in GitInfo
       
       Also updates docs and bumps bep/gitmap to v1.7.0
       
       Closes #5693
       
       Co-authored-by: bep <bjorn.erik.pedersen@gmail.com>
       
       Diffstat:
         M docs/content/en/methods/page/GitIn… |      16 ++++++++++++++++
         M go.mod                              |       2 +-
         M go.sum                              |       4 ++--
         M source/fileInfo.go                  |      24 +++++++++++++++++++++---
         M tpl/page/page_integration_test.go   |      20 ++++++++++++++++++++
       
       5 files changed, 60 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/docs/content/en/methods/page/GitInfo.md b/docs/content/en/methods/page/GitInfo.md
       @@ -117,6 +117,22 @@ hugo --enableGitInfo
        {{ end }}
        ```
        
       +###### Ancestor
       +
       +(`*source.GitInfo`) The file-filtered ancestor commit, if any.
       +
       +```go-html-template
       +{{ partial "inline/changelog.html" .GitInfo }} → 2023-10-09: Add tutorials
       +                                                 2025-03-26: Edit GitInfo docs
       +
       +{{ define "_partials/inline/changelog.html" }}
       +  {{ with . }}
       +    {{ partial "inline/changelog.html" .Ancestor }}
       +    {{ .CommitDate.Format "2006-01-02" }}: {{ .Subject }}<br>
       +  {{ end }}
       +{{ end }}
       +```
       +
        ## Last modified date
        
        By default, when `enableGitInfo` is `true`, the `Lastmod` method on a `Page` object returns the Git AuthorDate of the last commit that included the file.
   DIR diff --git a/go.mod b/go.mod
       @@ -8,7 +8,7 @@ require (
                github.com/aws/aws-sdk-go-v2/service/cloudfront v1.44.10
                github.com/bep/clocks v0.5.0
                github.com/bep/debounce v1.2.0
       -        github.com/bep/gitmap v1.6.0
       +        github.com/bep/gitmap v1.7.0
                github.com/bep/goat v0.5.0
                github.com/bep/godartsass/v2 v2.5.0
                github.com/bep/golibsass v1.2.0
   DIR diff --git a/go.sum b/go.sum
       @@ -141,8 +141,8 @@ github.com/bep/clocks v0.5.0 h1:hhvKVGLPQWRVsBP/UB7ErrHYIO42gINVbvqxvYTPVps=
        github.com/bep/clocks v0.5.0/go.mod h1:SUq3q+OOq41y2lRQqH5fsOoxN8GbxSiT6jvoVVLCVhU=
        github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
        github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
       -github.com/bep/gitmap v1.6.0 h1:sDuQMm9HoTL0LtlrfxjbjgAg2wHQd4nkMup2FInYzhA=
       -github.com/bep/gitmap v1.6.0/go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw=
       +github.com/bep/gitmap v1.7.0 h1:jvPnRQv5RG6IDPrwoDiwAhTE/DmdEkOW4poFeUYmjI8=
       +github.com/bep/gitmap v1.7.0/go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw=
        github.com/bep/goat v0.5.0 h1:S8jLXHCVy/EHIoCY+btKkmcxcXFd34a0Q63/0D4TKeA=
        github.com/bep/goat v0.5.0/go.mod h1:Md9x7gRxiWKs85yHlVTvHQw9rg86Bm+Y4SuYE8CTH7c=
        github.com/bep/godartsass/v2 v2.5.0 h1:tKRvwVdyjCIr48qgtLa4gHEdtRkPF8H1OeEhJAEv7xg=
   DIR diff --git a/source/fileInfo.go b/source/fileInfo.go
       @@ -155,7 +155,23 @@ func NewFileInfo(fi hugofs.FileMetaInfo) *File {
        }
        
        func NewGitInfo(info gitmap.GitInfo) GitInfo {
       -        return GitInfo(info)
       +        gi := GitInfo{
       +                Hash:            info.Hash,
       +                AbbreviatedHash: info.AbbreviatedHash,
       +                Subject:         info.Subject,
       +                AuthorName:      info.AuthorName,
       +                AuthorEmail:     info.AuthorEmail,
       +                AuthorDate:      info.AuthorDate,
       +                CommitDate:      info.CommitDate,
       +                Body:            info.Body,
       +        }
       +
       +        if info.Ancestor != nil {
       +                anc := NewGitInfo(*info.Ancestor)
       +                gi.Ancestor = &anc
       +        }
       +
       +        return gi
        }
        
        // GitInfo provides information about a version controlled source file.
       @@ -176,10 +192,12 @@ type GitInfo struct {
                CommitDate time.Time `json:"commitDate"`
                // The commit message's body.
                Body string `json:"body"`
       +        // The file-filtered ancestor commit, if any.
       +        Ancestor *GitInfo `json:"ancestor"`
        }
        
        // IsZero returns true if the GitInfo is empty,
        // meaning it will also be falsy in the Go templates.
       -func (g GitInfo) IsZero() bool {
       -        return g.Hash == ""
       +func (g *GitInfo) IsZero() bool {
       +        return g == nil || g.Hash == ""
        }
   DIR diff --git a/tpl/page/page_integration_test.go b/tpl/page/page_integration_test.go
       @@ -220,3 +220,23 @@ disableLiveReload = true
        
                b.AssertFileContent("public/index.html", "1\n2\n3")
        }
       +
       +func TestThatPageGitInfoShouldBeZero(t *testing.T) {
       +        t.Parallel()
       +
       +        files := `
       +-- hugo.toml --
       +disableKinds = ["taxonomy", "term"]
       +-- content/p1.md --
       +---
       +title: "P1"
       +---
       +-- layouts/all.html --
       +GitInfo: {{ with .GitInfo }}FAIL{{ end }}
       +
       +`
       +
       +        b := hugolib.Test(t, files)
       +
       +        b.AssertFileContent("public/p1/index.html", "! FAIL")
       +}