-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Add GitInfo #2291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GitInfo #2291
Conversation
|
This should work: git -C /Users/bep/go/src/github.com/spf13/hugo/ log --name-only --format=format:"%t|%aN|%aE|%ai|%s" HEAD |
|
I have updated the PR. There are still some small holes, but it is complete enough to know that it is doable. So if other could chime in with their opinions about:
/cc @spf13 |
316a2e5 to
13893e6
Compare
|
Haven't tested this, but I like the idea. 👍 Is the AbbreviatedHash necessary? That could be derived later from the Hash if you needed it. |
You get it for free, and that is the value I want to show on my pages (if any); it's not possible to derive it from the Hash from inside of a Hugo template. |
|
Which assumes 7 is a constant value. |
|
My understanding was that it's configurable (via the core.abbrev setting). Defaults to 7. If you change the setting in your repo, you could update your template to match. I just thought we could save memory allocs, but it's not that much of a win to drop it. You win. :) |
|
You kind of got a point, but it is simplest to let Git and the Git config win ... The memory loss is ... not much. Maybe Git-Junio will invent some smart "sliding abbreviated" hashes in the future ... Which is only length 3 for small repos ... |
|
Note to self: Maybe add a CLI flag for this as well, to make it easier to switch it off when in server mode etc. |
30f1276 to
6aa03c3
Compare
This commit adds a `GitInfo` object to `Page` if `EnableGitInfo` is set. It then also sets `Lastmod` for the given `Page` to the author date provided by Git. The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size. If you want, you can run without during development and turn it on when deploying to the live server: `hugo --enableGitInfo`. Fixes gohugoio#2102
|
This is ready now. It needs some docs, but that will have to wait. /cc @digitalcraftsman @moorereason @spf13 and gang. |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This commit adds a
GitInfoobject toPageifEnableGitInfois set.It then also sets
Lastmodfor the givenPageto the author date provided by Git.The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size.
If you want, you can run without during development and turn it on when deploying to the live server:
hugo --enableGitInfo.Fixes #2102