]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Make sure any default mounts show up in "hugo config"
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 1 Jun 2023 07:30:16 +0000 (09:30 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 1 Jun 2023 08:49:21 +0000 (10:49 +0200)
Fixes #11040

config/allconfig/allconfig.go
hugolib/config_test.go

index abb9555465871e3b76a08f44f46f5f6b58077ce3..40bb2221d472d0287bf95014f08997b1a77098fe 100644 (file)
@@ -649,6 +649,21 @@ func (c *Configs) Init() error {
                return err
        }
 
+       // We should consolidate this, but to get a full view of the mounts in e.g. "hugo config" we need to
+       // transfer any default mounts added above to the config used to print the config.
+       for _, m := range c.Modules[0].Mounts() {
+               var found bool
+               for _, cm := range c.Base.Module.Mounts {
+                       if cm.Source == m.Source && cm.Target == m.Target && cm.Lang == m.Lang {
+                               found = true
+                               break
+                       }
+               }
+               if !found {
+                       c.Base.Module.Mounts = append(c.Base.Module.Mounts, m)
+               }
+       }
+
        return nil
 }
 
index 814be667f06ec3e1d21d13592a7454d6f35f08a3..245180e12852a3711299a9f68d9a70bdeb978a21 100644 (file)
@@ -1151,3 +1151,29 @@ weight = 1
        })
 
 }
+
+// Issue #11040
+func TestConfigModuleDefaultMountsInConfig(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+baseURL = "https://example.org"
+contentDir = "mycontent"
+-- layouts/index.html --
+Home.
+
+       
+`
+       b := NewIntegrationTestBuilder(
+               IntegrationTestConfig{
+                       T:           t,
+                       TxtarString: files,
+               },
+       ).Build()
+
+       modConf := b.H.Configs.Base.Module
+
+       b.Assert(modConf.Mounts, qt.HasLen, 7)
+
+}