Skip to content

Add vcs.GetInfo or git.GetInfo template func #14465

@bep

Description

@bep

In have a in-progress Hugo branch that with the demo site in https://github.com/bep/hugo-testing-git-versions gives a convincing demonstration of:

  • The same content repo mounted with different Git versions.
  • .Page.GitInfo shows the correct commit info for these.

I'm going to try to wrap up that implementation in the near future, but that got me thinking about issues with the current API:

  1. It's Pages only; there's currently no way to print that info about e.g. an image.
  2. It's ... Git only.

I'm not so sure about the second one. But we may get us some future proofing by naming the package vcs.

With the above you would instead of:

{{ with .GitInfo }}
  Subject: {{ .Subject }}
{{ end }}

Write:

{{ with vcs.GetInfo . }}
  Subject: {{ .Subject }}
{{ end }}

And that would work for any* resource that's backed by a ... vcs.

  • the definition of any is a little vague at the moment, but ... most.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions