Skip to content

Commit a17bdbc

Browse files
jmooringbep
authored andcommitted
common/hugo: Deprecate extended and extended_withdeploy editions
Closes #14696
1 parent 8f94d65 commit a17bdbc

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

commands/commandeer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939

4040
"github.com/gohugoio/hugo/common/hstrings"
4141
"github.com/gohugoio/hugo/common/htime"
42+
"github.com/gohugoio/hugo/common/hugo"
4243
"github.com/gohugoio/hugo/common/loggers"
4344
"github.com/gohugoio/hugo/common/paths"
4445
"github.com/gohugoio/hugo/common/types"
@@ -454,6 +455,7 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
454455
}
455456
// Set up the global logger early to allow info deprecations during config load.
456457
loggers.SetGlobalLogger(r.logger)
458+
hugo.WarnDeprecatedEdition()
457459

458460
r.changesFromBuild = make(chan []identity.Identity, 10)
459461

common/hugo/hugo.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,18 @@ func IsDartSassGeV2() bool {
304304
return !strings.Contains(DartSassBinaryName, "embedded")
305305
}
306306

307+
// WarnDeprecatedEdition emits a deprecation warning if the running binary is
308+
// the extended or extended_withdeploy edition.
309+
func WarnDeprecatedEdition() {
310+
if IsExtended {
311+
if IsWithdeploy {
312+
Deprecate("the extended_withdeploy edition of the Hugo executable", "Use the withdeploy edition instead.", "v0.161.0")
313+
} else {
314+
Deprecate("the extended edition of the Hugo executable", "Use the standard edition instead.", "v0.161.0")
315+
}
316+
}
317+
}
318+
307319
// Deprecate informs about a deprecation starting at the given version.
308320
//
309321
// A deprecation typically needs a simple change in the template, but doing so will make the template incompatible with older versions.

common/hugo/hugo_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
package hugo
1515

1616
import (
17+
"bytes"
1718
"context"
1819
"testing"
1920

2021
"github.com/bep/logg"
2122
qt "github.com/frankban/quicktest"
23+
"github.com/gohugoio/hugo/common/loggers"
2224
)
2325

2426
func TestDeprecationLogLevelFromVersion(t *testing.T) {
@@ -59,3 +61,38 @@ func TestGetBuildInfo(t *testing.T) {
5961
c.Assert(bi.GoVersion, qt.Not(qt.Equals), "")
6062
}
6163
}
64+
65+
func TestWarnDeprecatedEdition(t *testing.T) {
66+
c := qt.New(t)
67+
68+
origExtended, origWithdeploy := IsExtended, IsWithdeploy
69+
t.Cleanup(func() {
70+
IsExtended = origExtended
71+
IsWithdeploy = origWithdeploy
72+
loggers.SetGlobalLogger(nil)
73+
})
74+
75+
var buf bytes.Buffer
76+
loggers.SetGlobalLogger(loggers.New(loggers.Options{Level: logg.LevelInfo, StdErr: &buf}))
77+
78+
IsExtended = true
79+
IsWithdeploy = false
80+
WarnDeprecatedEdition()
81+
c.Assert(buf.String(), qt.Contains, "the extended edition of the Hugo executable")
82+
c.Assert(buf.String(), qt.Contains, "Use the standard edition instead")
83+
84+
buf.Reset()
85+
86+
IsExtended = true
87+
IsWithdeploy = true
88+
WarnDeprecatedEdition()
89+
c.Assert(buf.String(), qt.Contains, "the extended_withdeploy edition of the Hugo executable")
90+
c.Assert(buf.String(), qt.Contains, "Use the withdeploy edition instead")
91+
92+
buf.Reset()
93+
94+
IsExtended = false
95+
IsWithdeploy = false
96+
WarnDeprecatedEdition()
97+
c.Assert(buf.String(), qt.Equals, "")
98+
}

testscripts/commands/hugo__minify_issue13988.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
hugo --minify --logLevel=info
22

3-
! stderr 'deprecated'
3+
! stderr 'deprecated.*minifyOutput'
44
grep '<p>one</p><p>two</p>' public/index.html
55

66
-- hugo.toml --

0 commit comments

Comments
 (0)