mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-20 16:22:49 +00:00
Compare commits
7 commits
e895dbffeb
...
9d4b021388
Author | SHA1 | Date | |
---|---|---|---|
9d4b021388 | |||
1961327536 | |||
cc3574ef4f | |||
fe84cc218e | |||
babcb339a8 | |||
7203a95a60 | |||
c7161b0117 |
4
cache/dynacache/dynacache.go
vendored
4
cache/dynacache/dynacache.go
vendored
|
@ -67,7 +67,7 @@ func New(opts Options) *Cache {
|
||||||
evictedIdentities := collections.NewStack[identity.Identity]()
|
evictedIdentities := collections.NewStack[identity.Identity]()
|
||||||
|
|
||||||
onEvict := func(k, v any) {
|
onEvict := func(k, v any) {
|
||||||
if !opts.Running {
|
if !opts.Watching {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
identity.WalkIdentitiesShallow(v, func(level int, id identity.Identity) bool {
|
identity.WalkIdentitiesShallow(v, func(level int, id identity.Identity) bool {
|
||||||
|
@ -97,7 +97,7 @@ type Options struct {
|
||||||
CheckInterval time.Duration
|
CheckInterval time.Duration
|
||||||
MaxSize int
|
MaxSize int
|
||||||
MinMaxSize int
|
MinMaxSize int
|
||||||
Running bool
|
Watching bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options for a partition.
|
// Options for a partition.
|
||||||
|
|
|
@ -209,7 +209,7 @@ func (c *newCommand) newSiteNextStepsText(path string, format string) string {
|
||||||
1. Change the current directory to ` + path + `.
|
1. Change the current directory to ` + path + `.
|
||||||
2. Create or install a theme:
|
2. Create or install a theme:
|
||||||
- Create a new theme with the command "hugo new theme <THEMENAME>"
|
- Create a new theme with the command "hugo new theme <THEMENAME>"
|
||||||
- Install a theme from https://themes.gohugo.io/
|
- Or, install a theme from https://themes.gohugo.io/
|
||||||
3. Edit hugo.` + format + `, setting the "theme" property to the theme name.
|
3. Edit hugo.` + format + `, setting the "theme" property to the theme name.
|
||||||
4. Create new content with the command "hugo new content `)
|
4. Create new content with the command "hugo new content `)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ package hugo
|
||||||
// This should be the only one.
|
// This should be the only one.
|
||||||
var CurrentVersion = Version{
|
var CurrentVersion = Version{
|
||||||
Major: 0,
|
Major: 0,
|
||||||
Minor: 125,
|
Minor: 126,
|
||||||
PatchLevel: 2,
|
PatchLevel: 0,
|
||||||
Suffix: "",
|
Suffix: "-DEV",
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ func (c ConfigLanguage) Environment() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ConfigLanguage) IsMultihost() bool {
|
func (c ConfigLanguage) IsMultihost() bool {
|
||||||
|
if len(c.m.Languages)-len(c.config.C.DisabledLanguages) <= 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return c.m.IsMultihost
|
return c.m.IsMultihost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
deps/deps.go
vendored
2
deps/deps.go
vendored
|
@ -155,7 +155,7 @@ func (d *Deps) Init() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.MemCache == nil {
|
if d.MemCache == nil {
|
||||||
d.MemCache = dynacache.New(dynacache.Options{Running: d.Conf.Running(), Log: d.Log})
|
d.MemCache = dynacache.New(dynacache.Options{Watching: d.Conf.Watching(), Log: d.Log})
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.PathSpec == nil {
|
if d.PathSpec == nil {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -5,7 +5,7 @@ require (
|
||||||
github.com/alecthomas/chroma/v2 v2.13.0
|
github.com/alecthomas/chroma/v2 v2.13.0
|
||||||
github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c
|
github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c
|
||||||
github.com/aws/aws-sdk-go-v2 v1.26.1
|
github.com/aws/aws-sdk-go-v2 v1.26.1
|
||||||
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.35.4
|
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.36.0
|
||||||
github.com/bep/clocks v0.5.0
|
github.com/bep/clocks v0.5.0
|
||||||
github.com/bep/debounce v1.2.0
|
github.com/bep/debounce v1.2.0
|
||||||
github.com/bep/gitmap v1.1.2
|
github.com/bep/gitmap v1.1.2
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -94,8 +94,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 h1:GrSw8s0Gs/5zZ0SX+gX4zQjRnRsM
|
||||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY=
|
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9 h1:ugD6qzjYtB7zM5PN/ZIeaAIyefPaD82G8+SJopgvUpw=
|
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9 h1:ugD6qzjYtB7zM5PN/ZIeaAIyefPaD82G8+SJopgvUpw=
|
||||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9/go.mod h1:YD0aYBWCrPENpHolhKw2XDlTIWae2GKXT1T4o6N6hiM=
|
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9/go.mod h1:YD0aYBWCrPENpHolhKw2XDlTIWae2GKXT1T4o6N6hiM=
|
||||||
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.35.4 h1:a4gfRHHCzvV0jEjOUdZOK0oJ4H21x5WT+E4ucWk4jeM=
|
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.36.0 h1:KbT1H0KXc26/M6km03gBWz5v1M5aOq4Cwo+aXJ2BpfM=
|
||||||
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.35.4/go.mod h1:Pphkts8iBnexoEpcMti5fUvN3/yoGRLtl2heOeppF70=
|
github.com/aws/aws-sdk-go-v2/service/cloudfront v1.36.0/go.mod h1:Pphkts8iBnexoEpcMti5fUvN3/yoGRLtl2heOeppF70=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 h1:/b31bi3YVNlkzkBrm9LfpaKoaYZUxIAj4sHfOTmLfqw=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 h1:/b31bi3YVNlkzkBrm9LfpaKoaYZUxIAj4sHfOTmLfqw=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4/go.mod h1:2aGXHFmbInwgP9ZfpmdIfOELL79zhdNYNmReK8qDfdQ=
|
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4/go.mod h1:2aGXHFmbInwgP9ZfpmdIfOELL79zhdNYNmReK8qDfdQ=
|
||||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.9 h1:/90OR2XbSYfXucBMJ4U14wrjlfleq/0SB6dZDPncgmo=
|
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.9 h1:/90OR2XbSYfXucBMJ4U14wrjlfleq/0SB6dZDPncgmo=
|
||||||
|
|
|
@ -252,3 +252,31 @@ Files: {{ range $files }}{{ .Permalink }}|{{ end }}$
|
||||||
b.AssertFileContent("public/en/enpages/mybundle-en/file2.txt", "File 2 en.")
|
b.AssertFileContent("public/en/enpages/mybundle-en/file2.txt", "File 2 en.")
|
||||||
b.AssertFileContent("public/fr/section/mybundle/file2.txt", "File 2 en.")
|
b.AssertFileContent("public/fr/section/mybundle/file2.txt", "File 2 en.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMultihostAllButOneLanguageDisabledIssue12288(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
defaultContentLanguage = "en"
|
||||||
|
disableLanguages = ["fr"]
|
||||||
|
#baseURL = "https://example.com"
|
||||||
|
[languages]
|
||||||
|
[languages.en]
|
||||||
|
baseURL = "https://example.en"
|
||||||
|
weight = 1
|
||||||
|
[languages.fr]
|
||||||
|
baseURL = "https://example.fr"
|
||||||
|
weight = 2
|
||||||
|
-- assets/css/main.css --
|
||||||
|
body { color: red; }
|
||||||
|
-- layouts/index.html --
|
||||||
|
{{ $css := resources.Get "css/main.css" | minify }}
|
||||||
|
CSS: {{ $css.Permalink }}|{{ $css.RelPermalink }}|
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/css/main.min.css", "body{color:red}")
|
||||||
|
b.AssertFileContent("public/index.html", "CSS: https://example.en/css/main.min.css|/css/main.min.css|")
|
||||||
|
}
|
||||||
|
|
|
@ -38,12 +38,20 @@ import (
|
||||||
|
|
||||||
type TestOpt func(*IntegrationTestConfig)
|
type TestOpt func(*IntegrationTestConfig)
|
||||||
|
|
||||||
|
// TestOptRunning will enable running in integration tests.
|
||||||
func TestOptRunning() TestOpt {
|
func TestOptRunning() TestOpt {
|
||||||
return func(c *IntegrationTestConfig) {
|
return func(c *IntegrationTestConfig) {
|
||||||
c.Running = true
|
c.Running = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestOptWatching will enable watching in integration tests.
|
||||||
|
func TestOptWatching() TestOpt {
|
||||||
|
return func(c *IntegrationTestConfig) {
|
||||||
|
c.Watching = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Enable tracing in integration tests.
|
// Enable tracing in integration tests.
|
||||||
// THis should only be used during development and not committed to the repo.
|
// THis should only be used during development and not committed to the repo.
|
||||||
func TestOptTrace() TestOpt {
|
func TestOptTrace() TestOpt {
|
||||||
|
@ -570,6 +578,10 @@ func (s *IntegrationTestBuilder) initBuilder() error {
|
||||||
"running": s.Cfg.Running,
|
"running": s.Cfg.Running,
|
||||||
"watch": s.Cfg.Running,
|
"watch": s.Cfg.Running,
|
||||||
})
|
})
|
||||||
|
} else if s.Cfg.Watching {
|
||||||
|
flags.Set("internal", maps.Params{
|
||||||
|
"watch": s.Cfg.Watching,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Cfg.WorkingDir != "" {
|
if s.Cfg.WorkingDir != "" {
|
||||||
|
@ -817,6 +829,11 @@ type IntegrationTestConfig struct {
|
||||||
// Whether to simulate server mode.
|
// Whether to simulate server mode.
|
||||||
Running bool
|
Running bool
|
||||||
|
|
||||||
|
// Watch for changes.
|
||||||
|
// This is (currently) always set to true when Running is set.
|
||||||
|
// Note that the CLI for the server does allow for --watch=false, but that is not used in these test.
|
||||||
|
Watching bool
|
||||||
|
|
||||||
// Will print the log buffer after the build
|
// Will print the log buffer after the build
|
||||||
Verbose bool
|
Verbose bool
|
||||||
|
|
||||||
|
|
|
@ -121,14 +121,23 @@ func TestRebuildEditTextFileInBranchBundle(t *testing.T) {
|
||||||
b.AssertRenderCountContent(1)
|
b.AssertRenderCountContent(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildRenameTextFileInLeafBundle(t *testing.T) {
|
func testRebuildBothWatchingAndRunning(t *testing.T, files string, withB func(b *IntegrationTestBuilder)) {
|
||||||
b := TestRunning(t, rebuildFilesSimple)
|
t.Helper()
|
||||||
b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
|
for _, opt := range []TestOpt{TestOptWatching(), TestOptRunning()} {
|
||||||
|
b := Test(t, files, opt)
|
||||||
|
withB(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
b.RenameFile("content/mysection/mysectionbundle/mysectionbundletext.txt", "content/mysection/mysectionbundle/mysectionbundletext2.txt").Build()
|
func TestRebuildRenameTextFileInLeafBundle(t *testing.T) {
|
||||||
b.AssertFileContent("public/mysection/mysectionbundle/index.html", "mysectionbundletext2", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
|
testRebuildBothWatchingAndRunning(t, rebuildFilesSimple, func(b *IntegrationTestBuilder) {
|
||||||
b.AssertRenderCountPage(3)
|
b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
|
||||||
b.AssertRenderCountContent(3)
|
|
||||||
|
b.RenameFile("content/mysection/mysectionbundle/mysectionbundletext.txt", "content/mysection/mysectionbundle/mysectionbundletext2.txt").Build()
|
||||||
|
b.AssertFileContent("public/mysection/mysectionbundle/index.html", "mysectionbundletext2", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
|
||||||
|
b.AssertRenderCountPage(3)
|
||||||
|
b.AssertRenderCountContent(3)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuilEditContentFileInLeafBundle(t *testing.T) {
|
func TestRebuilEditContentFileInLeafBundle(t *testing.T) {
|
||||||
|
@ -367,8 +376,6 @@ My short.
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildBaseof(t *testing.T) {
|
func TestRebuildBaseof(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
title = "Hugo Site"
|
title = "Hugo Site"
|
||||||
|
@ -383,12 +390,13 @@ Baseof: {{ .Title }}|
|
||||||
Home: {{ .Title }}|{{ .Content }}|
|
Home: {{ .Title }}|{{ .Content }}|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
`
|
`
|
||||||
b := Test(t, files, TestOptRunning())
|
testRebuildBothWatchingAndRunning(t, files, func(b *IntegrationTestBuilder) {
|
||||||
b.AssertFileContent("public/index.html", "Baseof: Hugo Site|", "Home: Hugo Site||")
|
b.AssertFileContent("public/index.html", "Baseof: Hugo Site|", "Home: Hugo Site||")
|
||||||
b.EditFileReplaceFunc("layouts/_default/baseof.html", func(s string) string {
|
b.EditFileReplaceFunc("layouts/_default/baseof.html", func(s string) string {
|
||||||
return strings.Replace(s, "Baseof", "Baseof Edited", 1)
|
return strings.Replace(s, "Baseof", "Baseof Edited", 1)
|
||||||
}).Build()
|
}).Build()
|
||||||
b.AssertFileContent("public/index.html", "Baseof Edited: Hugo Site|", "Home: Hugo Site||")
|
b.AssertFileContent("public/index.html", "Baseof Edited: Hugo Site|", "Home: Hugo Site||")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRebuildSingleWithBaseof(t *testing.T) {
|
func TestRebuildSingleWithBaseof(t *testing.T) {
|
||||||
|
|
|
@ -123,14 +123,14 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
|
||||||
HandlerPost: logHookLast,
|
HandlerPost: logHookLast,
|
||||||
Stdout: cfg.LogOut,
|
Stdout: cfg.LogOut,
|
||||||
Stderr: cfg.LogOut,
|
Stderr: cfg.LogOut,
|
||||||
StoreErrors: conf.Running(),
|
StoreErrors: conf.Watching(),
|
||||||
SuppressStatements: conf.IgnoredLogs(),
|
SuppressStatements: conf.IgnoredLogs(),
|
||||||
}
|
}
|
||||||
logger = loggers.New(logOpts)
|
logger = loggers.New(logOpts)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memCache := dynacache.New(dynacache.Options{Running: conf.Running(), Log: logger})
|
memCache := dynacache.New(dynacache.Options{Watching: conf.Watching(), Log: logger})
|
||||||
|
|
||||||
firstSiteDeps := &deps.Deps{
|
firstSiteDeps := &deps.Deps{
|
||||||
Fs: cfg.Fs,
|
Fs: cfg.Fs,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Release env.
|
# Release env.
|
||||||
# These will be replaced by script before release.
|
# These will be replaced by script before release.
|
||||||
HUGORELEASER_TAG=v0.125.1
|
HUGORELEASER_TAG=v0.125.4
|
||||||
HUGORELEASER_COMMITISH=68c5ad638c2072969e47262926b912e80fd71a77
|
HUGORELEASER_COMMITISH=cc3574ef4f41fccbe88d9443ed066eb10867ada2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type templateExecHelper struct {
|
type templateExecHelper struct {
|
||||||
running bool // whether we're in server mode.
|
watching bool // whether we're in server/watch mode.
|
||||||
site reflect.Value
|
site reflect.Value
|
||||||
siteParams reflect.Value
|
siteParams reflect.Value
|
||||||
funcs map[string]reflect.Value
|
funcs map[string]reflect.Value
|
||||||
|
@ -95,7 +95,7 @@ func (t *templateExecHelper) GetFunc(ctx context.Context, tmpl texttemplate.Prep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *templateExecHelper) Init(ctx context.Context, tmpl texttemplate.Preparer) {
|
func (t *templateExecHelper) Init(ctx context.Context, tmpl texttemplate.Preparer) {
|
||||||
if t.running {
|
if t.watching {
|
||||||
_, ok := tmpl.(identity.IdentityProvider)
|
_, ok := tmpl.(identity.IdentityProvider)
|
||||||
if ok {
|
if ok {
|
||||||
t.trackDependencies(ctx, tmpl, "", reflect.Value{})
|
t.trackDependencies(ctx, tmpl, "", reflect.Value{})
|
||||||
|
@ -129,7 +129,7 @@ func (t *templateExecHelper) GetMethod(ctx context.Context, tmpl texttemplate.Pr
|
||||||
name = "MainSections"
|
name = "MainSections"
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.running {
|
if t.watching {
|
||||||
ctx = t.trackDependencies(ctx, tmpl, name, receiver)
|
ctx = t.trackDependencies(ctx, tmpl, name, receiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ func (t *templateExecHelper) GetMethod(ctx context.Context, tmpl texttemplate.Pr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *templateExecHelper) OnCalled(ctx context.Context, tmpl texttemplate.Preparer, name string, args []reflect.Value, result reflect.Value) {
|
func (t *templateExecHelper) OnCalled(ctx context.Context, tmpl texttemplate.Preparer, name string, args []reflect.Value, result reflect.Value) {
|
||||||
if !t.running {
|
if !t.watching {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ func newTemplateExecuter(d *deps.Deps) (texttemplate.Executer, map[string]reflec
|
||||||
}
|
}
|
||||||
|
|
||||||
exeHelper := &templateExecHelper{
|
exeHelper := &templateExecHelper{
|
||||||
running: d.Conf.Running(),
|
watching: d.Conf.Watching(),
|
||||||
funcs: funcsv,
|
funcs: funcsv,
|
||||||
site: reflect.ValueOf(d.Site),
|
site: reflect.ValueOf(d.Site),
|
||||||
siteParams: reflect.ValueOf(d.Site.Params()),
|
siteParams: reflect.ValueOf(d.Site.Params()),
|
||||||
|
|
Loading…
Reference in a new issue