Repository: gohugoio/hugo (language: go)

Issue:
Adjust deprecation timing and message
I know this has been discussed before, but here's my thinking:

1. I suspect very few people, if any, use the `--logLevel info` flag to check for new deprecations. So we're effectively giving users a "6 releases from now" notice instead of a "12 releases from now" notice. I propose to start warning immediately, not after 6 releases.

2. After 12 releases we're telling people we're going to remove the feature, but from their perspective it has already been removed. I propose to adjust the message as shown below.


```diff
diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go
index eecf4bc2f..a1fe2b875 100644
--- a/common/hugo/hugo.go
+++ b/common/hugo/hugo.go
@@ -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)
 	}
@@ -437,10 +437,8 @@ func deprecationLogLevelFromVersion(ver string) logg.Level {
 	case minorDiff >= 12:
 		// Start failing the build after about a year.
 		return logg.LevelError
-	case minorDiff >= 6:
-		// Start printing warnings after about six months.
-		return logg.LevelWarn
 	default:
-		return logg.LevelInfo
+		// Start warning immediately.
+		return logg.LevelWarn
 	}
 }
````


Discussion / hints:

Fix patch:
diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go
index eecf4bc2f67..8b32432db0f 100644
--- a/common/hugo/hugo.go
+++ b/common/hugo/hugo.go
@@ -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)
 	}
@@ -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
diff --git a/tpl/debug/debug.go b/tpl/debug/debug.go
index fd676f0e21e..3909cbfa2f7 100644
--- a/tpl/debug/debug.go
+++ b/tpl/debug/debug.go
@@ -171,7 +171,7 @@ 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 ""
 }
@@ -179,7 +179,7 @@ func (ns *Namespace) TestDeprecationWarn(item, alternative string) string {
 // 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 ""
 }


Test patch:
diff --git a/common/hugo/hugo_test.go b/common/hugo/hugo_test.go
index feb52075df1..f938073dade 100644
--- a/common/hugo/hugo_test.go
+++ b/common/hugo/hugo_test.go
@@ -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.