From 3a7706b069107e5fa6112b3f7ce006f16867cb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 28 Jun 2018 12:20:03 +0200 Subject: [PATCH 1/5] commands: Fix broken server-reload on config changes This was accidently broken in Hugo 0.42. Fixes #4878 --- commands/commandeer.go | 37 +++++++++++++++++++++++-------------- commands/hugo.go | 11 ++--------- commands/server.go | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/commands/commandeer.go b/commands/commandeer.go index d5d2740bf..4ca0c4be9 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -37,23 +37,27 @@ import ( "github.com/gohugoio/hugo/langs" ) -type commandeer struct { +type commandeerHugoState struct { *deps.DepsCfg + hugo *hugolib.HugoSites + fsCreate sync.Once +} - hugo *hugolib.HugoSites +type commandeer struct { + *commandeerHugoState + + // We need to reuse this on server rebuilds. + destinationFs afero.Fs h *hugoBuilderCommon ftch flagsToConfigHandler visitedURLs *types.EvictingStringQueue - // We watch these for changes. - configFiles []string - doWithCommandeer func(c *commandeer) error - // We can do this only once. - fsCreate sync.Once + // We watch these for changes. + configFiles []string // Used in cases where we get flooded with events in server mode. debounce func(f func()) @@ -73,6 +77,7 @@ func (c *commandeer) Set(key string, value interface{}) { } func (c *commandeer) initFs(fs *hugofs.Fs) error { + c.destinationFs = fs.Destination c.DepsCfg.Fs = fs return nil @@ -89,11 +94,12 @@ func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f fla } c := &commandeer{ - h: h, - ftch: f, - doWithCommandeer: doWithCommandeer, - visitedURLs: types.NewEvictingStringQueue(10), - debounce: rebuildDebouncer, + h: h, + ftch: f, + commandeerHugoState: &commandeerHugoState{}, + doWithCommandeer: doWithCommandeer, + visitedURLs: types.NewEvictingStringQueue(10), + debounce: rebuildDebouncer, } return c, c.loadConfig(mustHaveConfigFile, running) @@ -188,8 +194,11 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error { c.fsCreate.Do(func() { fs := hugofs.NewFrom(sourceFs, config) - // Hugo writes the output to memory instead of the disk. - if createMemFs { + if c.destinationFs != nil { + // Need to reuse the destination on server rebuilds. + fs.Destination = c.destinationFs + } else if createMemFs { + // Hugo writes the output to memory instead of the disk. fs.Destination = new(afero.MemMapFs) } diff --git a/commands/hugo.go b/commands/hugo.go index 5c87bd96e..2b847ec95 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -596,14 +596,6 @@ func (c *commandeer) getDirList() ([]string, error) { return a, nil } -func (c *commandeer) recreateAndBuildSites(watching bool) (err error) { - defer c.timeTrack(time.Now(), "Total") - if !c.h.quiet { - c.Logger.FEEDBACK.Println("Started building sites ...") - } - return c.hugo.Build(hugolib.BuildCfg{CreateSitesFromConfig: true}) -} - func (c *commandeer) resetAndBuildSites() (err error) { if !c.h.quiet { c.Logger.FEEDBACK.Println("Started building sites ...") @@ -637,9 +629,10 @@ func (c *commandeer) rebuildSites(events []fsnotify.Event) error { } func (c *commandeer) fullRebuild() { + c.commandeerHugoState = &commandeerHugoState{} if err := c.loadConfig(true, true); err != nil { jww.ERROR.Println("Failed to reload config:", err) - } else if err := c.recreateAndBuildSites(true); err != nil { + } else if err := c.buildSites(); err != nil { jww.ERROR.Println(err) } else if !c.h.buildWatch && !c.Cfg.GetBool("disableLiveReload") { livereload.ForceRefresh() diff --git a/commands/server.go b/commands/server.go index 8089b0ade..fde881f6f 100644 --- a/commands/server.go +++ b/commands/server.go @@ -298,7 +298,7 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, string, string, erro } } - httpFs := afero.NewHttpFs(f.c.Fs.Destination) + httpFs := afero.NewHttpFs(f.c.destinationFs) fs := filesOnlyFs{httpFs.Dir(absPublishDir)} doLiveReload := !f.s.buildWatch && !f.c.Cfg.GetBool("disableLiveReload") From 1637d12e3762fc1ebab4cd675f75afaf25f59cdb Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Thu, 28 Jun 2018 12:29:44 +0000 Subject: [PATCH 2/5] Release 0.42.2 --- temp/0.42.2-relnotes-ready.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 temp/0.42.2-relnotes-ready.md diff --git a/temp/0.42.2-relnotes-ready.md b/temp/0.42.2-relnotes-ready.md new file mode 100644 index 000000000..f748a5153 --- /dev/null +++ b/temp/0.42.2-relnotes-ready.md @@ -0,0 +1,8 @@ + + + This release fixe broken server-reload on config changes. This is a regression from Hugo `0.42`. [3a7706b0](https://github.com/gohugoio/hugo/commit/3a7706b069107e5fa6112b3f7ce006f16867cb38) [@bep](https://github.com/bep) [#4878](https://github.com/gohugoio/hugo/issues/4878) + + + + + From d2640fbc194f49d5c9c90a8ae70f04469b856f9d Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Thu, 28 Jun 2018 12:36:15 +0000 Subject: [PATCH 3/5] releaser: Bump versions for release of 0.42.2 [ci skip] --- docs/config.toml | 2 +- helpers/hugo.go | 2 +- snapcraft.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/config.toml b/docs/config.toml index 681b79665..61864c64f 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -70,7 +70,7 @@ twitter = "GoHugoIO" [params] description = "The world’s fastest framework for building websites" ## Used for views in rendered HTML (i.e., rather than using the .Hugo variable) - release = "0.42.1" + release = "0.42.2" ## Setting this to true will add a "noindex" to *EVERY* page on the site removefromexternalsearch = false ## Gh repo for site footer (include trailing slash) diff --git a/helpers/hugo.go b/helpers/hugo.go index ec0a68310..faa3bca81 100644 --- a/helpers/hugo.go +++ b/helpers/hugo.go @@ -124,7 +124,7 @@ func (v HugoVersion) NextPatchLevel(level int) HugoVersion { // This should be the only one. var CurrentHugoVersion = HugoVersion{ Number: 0.42, - PatchLevel: 1, + PatchLevel: 2, Suffix: "", } diff --git a/snapcraft.yaml b/snapcraft.yaml index aeed2f916..47fabc4ea 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,5 +1,5 @@ name: hugo -version: "0.42.1" +version: "0.42.2" summary: Fast and Flexible Static Site Generator description: | Hugo is a static HTML and CSS website generator written in Go. It is From 02aa3200307a35c086707533c08ad6bf95a0f9d5 Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Thu, 28 Jun 2018 12:36:15 +0000 Subject: [PATCH 4/5] releaser: Add release notes to /docs for release of 0.42.2 [ci skip] --- docs/content/en/news/0.42.2-relnotes/index.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/content/en/news/0.42.2-relnotes/index.md diff --git a/docs/content/en/news/0.42.2-relnotes/index.md b/docs/content/en/news/0.42.2-relnotes/index.md new file mode 100644 index 000000000..f680b560f --- /dev/null +++ b/docs/content/en/news/0.42.2-relnotes/index.md @@ -0,0 +1,19 @@ + +--- +date: 2018-06-28 +title: "0.42.2" +description: "0.42.2" +categories: ["Releases"] +images: +- images/blog/hugo-bug-poster.png + +--- + + + + This release fixe broken server-reload on config changes. This is a regression from Hugo `0.42`. [3a7706b0](https://github.com/gohugoio/hugo/commit/3a7706b069107e5fa6112b3f7ce006f16867cb38) [@bep](https://github.com/bep) [#4878](https://github.com/gohugoio/hugo/issues/4878) + + + + + From 360fa12213fe85b2f1ffa18f5d4d5301ca43a721 Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Thu, 28 Jun 2018 12:38:48 +0000 Subject: [PATCH 5/5] releaser: Prepare repository for 0.43-DEV [ci skip] --- docs/config.toml | 2 +- helpers/hugo.go | 6 +++--- snapcraft.yaml | 4 ++-- temp/0.42.2-relnotes-ready.md | 8 -------- 4 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 temp/0.42.2-relnotes-ready.md diff --git a/docs/config.toml b/docs/config.toml index 61864c64f..1c9307a35 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -70,7 +70,7 @@ twitter = "GoHugoIO" [params] description = "The world’s fastest framework for building websites" ## Used for views in rendered HTML (i.e., rather than using the .Hugo variable) - release = "0.42.2" + release = "0.43-DEV" ## Setting this to true will add a "noindex" to *EVERY* page on the site removefromexternalsearch = false ## Gh repo for site footer (include trailing slash) diff --git a/helpers/hugo.go b/helpers/hugo.go index faa3bca81..1acd41fdb 100644 --- a/helpers/hugo.go +++ b/helpers/hugo.go @@ -123,9 +123,9 @@ func (v HugoVersion) NextPatchLevel(level int) HugoVersion { // CurrentHugoVersion represents the current build version. // This should be the only one. var CurrentHugoVersion = HugoVersion{ - Number: 0.42, - PatchLevel: 2, - Suffix: "", + Number: 0.43, + PatchLevel: 0, + Suffix: "-DEV", } func hugoVersion(version float32, patchVersion int, suffix string) string { diff --git a/snapcraft.yaml b/snapcraft.yaml index 47fabc4ea..787fbd4e8 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,12 +1,12 @@ name: hugo -version: "0.42.2" +version: "0.43-DEV" summary: Fast and Flexible Static Site Generator description: | Hugo is a static HTML and CSS website generator written in Go. It is optimized for speed, easy use and configurability. Hugo takes a directory with content and templates and renders them into a full HTML website. confinement: strict -grade: stable # "devel" or "stable" +grade: devel # "devel" or "stable" apps: hugo: diff --git a/temp/0.42.2-relnotes-ready.md b/temp/0.42.2-relnotes-ready.md deleted file mode 100644 index f748a5153..000000000 --- a/temp/0.42.2-relnotes-ready.md +++ /dev/null @@ -1,8 +0,0 @@ - - - This release fixe broken server-reload on config changes. This is a regression from Hugo `0.42`. [3a7706b0](https://github.com/gohugoio/hugo/commit/3a7706b069107e5fa6112b3f7ce006f16867cb38) [@bep](https://github.com/bep) [#4878](https://github.com/gohugoio/hugo/issues/4878) - - - - -