aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-12-19 15:50:53 +0100
committerBjørn Erik Pedersen <[email protected]>2022-12-19 20:17:33 +0100
commit6db527483dec048fbcc5735c41b137a8eb6508e4 (patch)
treef94582a932a43b5a61638cd81105e63e7e9c2d7d
parent0d4b17d4c03bfcbe3a5959e2c1dc47f4f36e47ed (diff)
downloadhugo-6db527483dec048fbcc5735c41b137a8eb6508e4.tar.gz
hugo-6db527483dec048fbcc5735c41b137a8eb6508e4.zip
Add any configured Go Workspace file to the config watcher
Fixes #10556
-rw-r--r--commands/hugo.go4
-rw-r--r--hugolib/config.go10
-rw-r--r--modules/collect.go13
-rw-r--r--modules/config.go4
4 files changed, 27 insertions, 4 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index e247fca27..d2d99c7fa 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -924,6 +924,7 @@ func (c *commandeer) printChangeDetected(typ string) {
const (
configChangeConfig = "config file"
configChangeGoMod = "go.mod file"
+ configChangeGoWork = "go work file"
)
func (c *commandeer) handleEvents(watcher *watcher.Batcher,
@@ -943,6 +944,9 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
if strings.Contains(ev.Name, "go.mod") {
configChangeType = configChangeGoMod
}
+ if strings.Contains(ev.Name, ".work") {
+ configChangeType = configChangeGoWork
+ }
}
if !isConfig {
// It may be one of the /config folders
diff --git a/hugolib/config.go b/hugolib/config.go
index 8444d15d9..9ccb87014 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -417,12 +417,18 @@ func (l configLoader) collectModules(modConfig modules.Config, v1 config.Provide
// Avoid recreating these later.
v1.Set("allModules", moduleConfig.ActiveModules)
+ // We want to watch these for changes and trigger rebuild on version
+ // changes etc.
if moduleConfig.GoModulesFilename != "" {
- // We want to watch this for changes and trigger rebuild on version
- // changes etc.
+
configFilenames = append(configFilenames, moduleConfig.GoModulesFilename)
}
+ if moduleConfig.GoWorkspaceFilename != "" {
+ configFilenames = append(configFilenames, moduleConfig.GoWorkspaceFilename)
+
+ }
+
return moduleConfig.ActiveModules, configFilenames, err
}
diff --git a/modules/collect.go b/modules/collect.go
index 7d92e3045..ae6df9be9 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -107,9 +107,15 @@ func (h *Client) collect(tidy bool) (ModulesConfig, *collector) {
}
}*/
+ var workspaceFilename string
+ if h.ccfg.ModuleConfig.Workspace != WorkspaceDisabled {
+ workspaceFilename = h.ccfg.ModuleConfig.Workspace
+ }
+
return ModulesConfig{
- AllModules: c.modules,
- GoModulesFilename: c.GoModulesFilename,
+ AllModules: c.modules,
+ GoModulesFilename: c.GoModulesFilename,
+ GoWorkspaceFilename: workspaceFilename,
}, c
}
@@ -122,6 +128,9 @@ type ModulesConfig struct {
// Set if this is a Go modules enabled project.
GoModulesFilename string
+
+ // Set if a Go workspace file is configured.
+ GoWorkspaceFilename string
}
func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error {
diff --git a/modules/config.go b/modules/config.go
index 86166300a..c08d2a4ab 100644
--- a/modules/config.go
+++ b/modules/config.go
@@ -15,6 +15,7 @@ package modules
import (
"fmt"
+ "os"
"path/filepath"
"strings"
@@ -261,6 +262,9 @@ func decodeConfig(cfg config.Provider, pathReplacements map[string]string) (Conf
workingDir := cfg.GetString("workingDir")
c.Workspace = filepath.Join(workingDir, c.Workspace)
}
+ if _, err := os.Stat(c.Workspace); err != nil {
+ return c, fmt.Errorf("module workspace %q does not exist", c.Workspace)
+ }
}
}