]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix regression with site.IsServer when not running a server
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 May 2023 07:26:30 +0000 (09:26 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 24 May 2023 10:42:56 +0000 (12:42 +0200)
Fixes #11006

commands/commandeer.go
commands/server.go
hugolib/hugo_sites_build.go
hugolib/integrationtest_builder.go
hugolib/page.go
hugolib/page__per_output.go
hugolib/site.go
hugolib/site_new.go
hugolib/testhelpers_test.go
testscripts/commands/hugo.txt

index 912a55780ec0121b181408da52b8c372981f3b30..08f959579b0883d6c4c346861ab0f60c8801941c 100644 (file)
@@ -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
        }
 
index b42cb1ed32c9e705b00d0740fa6f3b1129cf5d1a..a288bb2c80604717b9e1d29c0fa2c572a014eecc 100644 (file)
@@ -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 {
index 3464385d33e17cf99bf72c0e504a72622c0a43b4..c801ae3dff6dcada9092713dba44c3654538d1d3 100644 (file)
@@ -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")
        }
 
index 02add495c1e4a1f966545384eb73db1f1e4dd8ff..4993d922a549342cc426ff4fa1eeb93853c6f8f8 100644 (file)
@@ -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,
                        })
                }
 
index 2e6b6c36fab2f66a524ff245bc7ce3c9c0a94f18..2644c8e4e34ca3e7a3f910b6c2f9ad79a0279e27 100644 (file)
@@ -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)
index 4817d9a0c9dd1763536d3c28b9f4b32ab09f932c..65809a377867912c543bf68e30bfb19ca5b365bb 100644 (file)
@@ -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)
        }
 
index 8e220f63369c309c5af0dd8f0349216a57733c3f..d23a903856e0e571126439f0794fa48f6e322067 100644 (file)
@@ -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()
                }
 
index 1262cc3aeea1c967938ab4e6c6edd812e1c1b8f3..e5398ba8d3dfbc08c75b2a7f549e509d852a606c 100644 (file)
@@ -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),
index 0ba861fdb81aa091c88bce7369593d6f019a598f..7cf1a55965b8c826dd23cd1c034a893e9ed73dc5 100644 (file)
@@ -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 != "" {
index 7dfabe59203b27f97c94d6aa25a25bed96b004c0..9907f525856b74c6905b7edb9145b8bcfc6b0fb7 100644 (file)
@@ -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 --