summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-24 09:26:30 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-05-24 12:42:56 +0200
commit9a235d0afca6125f7cf222ae0d66a5fe91ae8694 (patch)
tree00d0b6b3edfda3e7e2ca90f0e6def9e64d301912
parent99407c39ba92b3bfc569a505b05033e04b242e8d (diff)
Fix regression with site.IsServer when not running a server
Fixes #11006
-rw-r--r--commands/commandeer.go2
-rw-r--r--commands/server.go2
-rw-r--r--hugolib/hugo_sites_build.go2
-rw-r--r--hugolib/integrationtest_builder.go1
-rw-r--r--hugolib/page.go2
-rw-r--r--hugolib/page__per_output.go2
-rw-r--r--hugolib/site.go6
-rw-r--r--hugolib/site_new.go2
-rw-r--r--hugolib/testhelpers_test.go1
-rw-r--r--testscripts/commands/hugo.txt3
10 files changed, 13 insertions, 10 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go
index 912a55780..08f959579 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -339,7 +339,7 @@ func (r *rootCommand) Run(ctx context.Context, cd *simplecobra.Commandeer, args
b := newHugoBuilder(r, nil)
- if err := b.loadConfig(cd, true); err != nil {
+ if err := b.loadConfig(cd, false); err != nil {
return err
}
diff --git a/commands/server.go b/commands/server.go
index b42cb1ed3..a288bb2c8 100644
--- a/commands/server.go
+++ b/commands/server.go
@@ -204,7 +204,7 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string
listener := f.c.serverPorts[i].ln
logger := f.c.r.logger
- r.Printf("Environment: %q", f.c.hugoTry().Deps.Site.Hugo().Environment)
+ r.Printf("Environment: %q\n", f.c.hugoTry().Deps.Site.Hugo().Environment)
if i == 0 {
if f.c.renderToDisk {
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 3464385d3..c801ae3df 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -185,7 +185,7 @@ func (h *HugoSites) initRebuild(config *BuildCfg) error {
return errors.New("rebuild does not support 'ResetState'")
}
- if !h.Configs.Base.Internal.Running {
+ if !h.Configs.Base.Internal.Watch {
return errors.New("rebuild called when not in watch mode")
}
diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go
index 02add495c..4993d922a 100644
--- a/hugolib/integrationtest_builder.go
+++ b/hugolib/integrationtest_builder.go
@@ -327,6 +327,7 @@ func (s *IntegrationTestBuilder) initBuilder() error {
if s.Cfg.Running {
flags.Set("internal", maps.Params{
"running": s.Cfg.Running,
+ "watch": s.Cfg.Running,
})
}
diff --git a/hugolib/page.go b/hugolib/page.go
index 2e6b6c36f..2644c8e4e 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -583,7 +583,7 @@ var defaultRenderStringOpts = renderStringOpts{
}
func (p *pageState) addDependency(dep identity.Provider) {
- if !p.s.running() || p.pageOutput.cp == nil {
+ if !p.s.watching() || p.pageOutput.cp == nil {
return
}
p.pageOutput.cp.dependencyTracker.Add(dep)
diff --git a/hugolib/page__per_output.go b/hugolib/page__per_output.go
index 4817d9a0c..65809a377 100644
--- a/hugolib/page__per_output.go
+++ b/hugolib/page__per_output.go
@@ -76,7 +76,7 @@ func newPageContentOutput(p *pageState, po *pageOutput) (*pageContentOutput, err
parent := p.init
var dependencyTracker identity.Manager
- if p.s.running() {
+ if p.s.watching() {
dependencyTracker = identity.NewManager(pageContentOutputDependenciesID)
}
diff --git a/hugolib/site.go b/hugolib/site.go
index 8e220f633..d23a90385 100644
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -389,8 +389,8 @@ func (s *siteRefLinker) refLink(ref string, source any, relative bool, outputFor
return link, nil
}
-func (s *Site) running() bool {
- return s.h != nil && s.h.Configs.Base.Internal.Running
+func (s *Site) watching() bool {
+ return s.h != nil && s.h.Configs.Base.Internal.Watch
}
type whatChanged struct {
@@ -1064,7 +1064,7 @@ func (s *Site) renderAndWritePage(statCounter *uint64, name string, targetPath s
pd.AbsURLPath = s.absURLPath(targetPath)
}
- if s.running() && s.conf.Internal.Watch && !s.conf.Internal.DisableLiveReload {
+ if s.watching() && s.conf.Internal.Watch && !s.conf.Internal.DisableLiveReload {
pd.LiveReloadBaseURL = s.Conf.BaseURLLiveReload().URL()
}
diff --git a/hugolib/site_new.go b/hugolib/site_new.go
index 1262cc3ae..e5398ba8d 100644
--- a/hugolib/site_new.go
+++ b/hugolib/site_new.go
@@ -280,7 +280,7 @@ func newHugoSitesNew(cfg deps.DepsCfg, d *deps.Deps, sites []*Site) (*HugoSites,
}
// Only needed in server mode.
- if cfg.Configs.Base.Internal.Running {
+ if cfg.Configs.Base.Internal.Watch {
h.ContentChanges = &contentChangeMap{
pathSpec: h.PathSpec,
symContent: make(map[string]map[string]bool),
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
index 0ba861fdb..7cf1a5596 100644
--- a/hugolib/testhelpers_test.go
+++ b/hugolib/testhelpers_test.go
@@ -486,6 +486,7 @@ func (s *sitesBuilder) LoadConfig() error {
flags := config.New()
flags.Set("internal", map[string]any{
"running": s.running,
+ "watch": s.running,
})
if s.workingDir != "" {
diff --git a/testscripts/commands/hugo.txt b/testscripts/commands/hugo.txt
index 7dfabe592..9907f5258 100644
--- a/testscripts/commands/hugo.txt
+++ b/testscripts/commands/hugo.txt
@@ -5,12 +5,13 @@ stdout 'Pages.*|1'
stdout 'Total in'
checkfile public/index.html
checkfile public/p1/index.html
+grep 'IsServer: false' public/index.html
-- hugo.toml --
baseURL = "http://example.org/"
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
-- layouts/index.html --
-Home.
+Home|IsServer: {{ .Site.IsServer }}|
-- layouts/_default/single.html --
Title: {{ .Title }}
-- content/p1.md --