]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
deps: Upgrade github.com/bep/gitmap v1.4.0 => v1.6.0 (note)
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 17 Jul 2024 07:15:44 +0000 (09:15 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 17 Jul 2024 08:54:28 +0000 (10:54 +0200)
Closes #8627

config/security/securityConfig.go
config/security/securityConfig_test.go
go.mod
go.sum
hugolib/gitinfo.go
hugolib/hugo_sites.go

index 46a5d0a23082fa8d0e6f1457bde1e6a2e65a75cb..a3ec5197d1a78ef2aff0a77ed1c5b596f858490d 100644 (file)
@@ -37,6 +37,7 @@ var DefaultConfig = Config{
                Allow: MustNewWhitelist(
                        "^(dart-)?sass(-embedded)?$", // sass, dart-sass, dart-sass-embedded.
                        "^go$",                       // for Go Modules
+                       "^git$",                      // For Git info
                        "^npx$",                      // used by all Node tools (Babel, PostCSS).
                        "^postcss$",
                        "^tailwindcss$",
index 87a2430125977f2dac4fed9508362f33212ad308..faa05a97f8bea01905aa0030d652b35ad1e1f44b 100644 (file)
@@ -135,7 +135,7 @@ func TestToTOML(t *testing.T) {
        got := DefaultConfig.ToTOML()
 
        c.Assert(got, qt.Equals,
-               "[security]\n  enableInlineShortcodes = false\n\n  [security.exec]\n    allow = ['^(dart-)?sass(-embedded)?$', '^go$', '^npx$', '^postcss$', '^tailwindcss$']\n    osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE)$']\n\n  [security.funcs]\n    getenv = ['^HUGO_', '^CI$']\n\n  [security.http]\n    methods = ['(?i)GET|POST']\n    urls = ['.*']",
+               "[security]\n  enableInlineShortcodes = false\n\n  [security.exec]\n    allow = ['^(dart-)?sass(-embedded)?$', '^go$', '^git$', '^npx$', '^postcss$', '^tailwindcss$']\n    osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE)$']\n\n  [security.funcs]\n    getenv = ['^HUGO_', '^CI$']\n\n  [security.http]\n    methods = ['(?i)GET|POST']\n    urls = ['.*']",
        )
 }
 
diff --git a/go.mod b/go.mod
index b9b5860722ec73da345040a8cabd4a5c4b8c95e3..2b7327aa33655f64c6efeb8c26307a144a91b68d 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
        github.com/aws/aws-sdk-go-v2/service/cloudfront v1.35.4
        github.com/bep/clocks v0.5.0
        github.com/bep/debounce v1.2.0
-       github.com/bep/gitmap v1.4.0
+       github.com/bep/gitmap v1.6.0
        github.com/bep/goat v0.5.0
        github.com/bep/godartsass v1.2.0
        github.com/bep/godartsass/v2 v2.0.0
diff --git a/go.sum b/go.sum
index 54a4a376ca97ae97c1b5aef2cc70556a89113bec..801a32cd2110d19d1f989a706cda7ffc3d598420 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -120,6 +120,10 @@ 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.4.0 h1:GeWbPb2QDTfcZLBQmCB693N3sJmPQfeu81fDrD5r8x8=
 github.com/bep/gitmap v1.4.0/go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw=
+github.com/bep/gitmap v1.5.0 h1:ExDl7HeDaRDG8FXFRTnv20qzbyJlC6ivdOboMYFvrms=
+github.com/bep/gitmap v1.5.0/go.mod h1:n+3W1f/rot2hynsqEGxGMErPRgT41n9CkGuzPvz9cIw=
+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/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 v1.2.0 h1:E2VvQrxAHAFwbjyOIExAMmogTItSKodoKuijNrGm5yU=
index f0c5dfa2759edefa827d41f5548943f98ebd2c46..6b5261084f2fd79964c4d15453215c3a8467218d 100644 (file)
 package hugolib
 
 import (
+       "io"
        "path/filepath"
        "strings"
 
        "github.com/bep/gitmap"
-       "github.com/gohugoio/hugo/config"
+       "github.com/gohugoio/hugo/common/hexec"
+       "github.com/gohugoio/hugo/deps"
        "github.com/gohugoio/hugo/resources/page"
        "github.com/gohugoio/hugo/source"
 )
@@ -38,10 +40,24 @@ func (g *gitInfo) forPage(p page.Page) source.GitInfo {
        return source.NewGitInfo(*gi)
 }
 
-func newGitInfo(conf config.AllProvider) (*gitInfo, error) {
-       workingDir := conf.BaseConfig().WorkingDir
+func newGitInfo(d *deps.Deps) (*gitInfo, error) {
+       opts := gitmap.Options{
+               Repository: d.Conf.BaseConfig().WorkingDir,
+               GetGitCommandFunc: func(stdout, stderr io.Writer, args ...string) (gitmap.Runner, error) {
+                       var argsv []any
+                       for _, arg := range args {
+                               argsv = append(argsv, arg)
+                       }
+                       argsv = append(
+                               argsv,
+                               hexec.WithStdout(stdout),
+                               hexec.WithStderr(stderr),
+                       )
+                       return d.ExecHelper.New("git", argsv...)
+               },
+       }
 
-       gitRepo, err := gitmap.Map(workingDir, "")
+       gitRepo, err := gitmap.Map(opts)
        if err != nil {
                return nil, err
        }
index 25a79d65a9ed392d0df9d9ec6a8280fc9b354c9a..659a772f22250c3de5a492f47f8929900bbc30c2 100644 (file)
@@ -346,7 +346,7 @@ func (h *HugoSites) GetContentPage(filename string) page.Page {
 
 func (h *HugoSites) loadGitInfo() error {
        if h.Configs.Base.EnableGitInfo {
-               gi, err := newGitInfo(h.Conf)
+               gi, err := newGitInfo(h.Deps)
                if err != nil {
                        h.Log.Errorln("Failed to read Git log:", err)
                } else {