Skip to content

Commit

Permalink
common/hugo: Adjust deprecation timing and message
Browse files Browse the repository at this point in the history
Closes #13333
  • Loading branch information
jmooring committed Feb 2, 2025
1 parent 05e067c commit 6892cce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions common/hugo/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func Deprecate(item, alternative string, version string) {
func DeprecateLevel(item, alternative, version string, level logg.Level) {
var msg string
if level == logg.LevelError {
msg = fmt.Sprintf("%s was deprecated in Hugo %s and will be removed in Hugo %s. %s", item, version, CurrentVersion.Next().ReleaseVersion(), alternative)
msg = fmt.Sprintf("%s was deprecated in Hugo %s and subsequently removed. %s", item, version, alternative)
} else {
msg = fmt.Sprintf("%s was deprecated in Hugo %s and will be removed in a future release. %s", item, version, alternative)
}
Expand All @@ -434,11 +434,11 @@ func deprecationLogLevelFromVersion(ver string) logg.Level {
to := CurrentVersion
minorDiff := to.Minor - from.Minor
switch {
case minorDiff >= 12:
// Start failing the build after about a year.
case minorDiff >= 15:
// Start failing the build after about 15 months.
return logg.LevelError
case minorDiff >= 6:
// Start printing warnings after about six months.
case minorDiff >= 3:
// Start printing warnings after about 3 months.
return logg.LevelWarn
default:
return logg.LevelInfo
Expand Down
8 changes: 4 additions & 4 deletions common/hugo/hugo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func TestDeprecationLogLevelFromVersion(t *testing.T) {
c.Assert(deprecationLogLevelFromVersion("0.55.0"), qt.Equals, logg.LevelError)
ver := CurrentVersion
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelInfo)
ver.Minor -= 1
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelInfo)
ver.Minor -= 6
ver.Minor -= 3
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelWarn)
ver.Minor -= 4
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelWarn)
ver.Minor -= 6
ver.Minor -= 13
c.Assert(deprecationLogLevelFromVersion(ver.String()), qt.Equals, logg.LevelError)

// Added just to find the threshold for where we can remove deprecated items.
Expand Down
4 changes: 2 additions & 2 deletions tpl/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ func (ns *Namespace) TestDeprecationInfo(item, alternative string) string {
// Internal template func, used in tests only.
func (ns *Namespace) TestDeprecationWarn(item, alternative string) string {
v := hugo.CurrentVersion
v.Minor -= 6
v.Minor -= 3
hugo.Deprecate(item, alternative, v.String())
return ""
}

// Internal template func, used in tests only.
func (ns *Namespace) TestDeprecationErr(item, alternative string) string {
v := hugo.CurrentVersion
v.Minor -= 12
v.Minor -= 15
hugo.Deprecate(item, alternative, v.String())
return ""
}

0 comments on commit 6892cce

Please sign in to comment.