From 6e9d2bf0c936900f8f676d485098755b3f463373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 20 Apr 2021 12:05:25 +0200 Subject: [PATCH 1/5] Regression in media type suffix lookup Introduced in Hugo 0.82.0. Fixes #8406 --- media/mediaType.go | 2 +- media/mediaType_test.go | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/media/mediaType.go b/media/mediaType.go index a35d80e3e..cba26ed2b 100644 --- a/media/mediaType.go +++ b/media/mediaType.go @@ -303,7 +303,7 @@ func (t Types) GetBySuffix(suffix string) (tp Type, si SuffixInfo, found bool) { } func (m Type) hasSuffix(suffix string) bool { - return strings.Contains(m.suffixesCSV, suffix) + return strings.Contains(","+m.suffixesCSV+",", ","+suffix+",") } // GetByMainSubType gets a media type given a main and a sub type e.g. "text" and "plain". diff --git a/media/mediaType_test.go b/media/mediaType_test.go index e44ab27ec..587d54e10 100644 --- a/media/mediaType_test.go +++ b/media/mediaType_test.go @@ -15,6 +15,7 @@ package media import ( "encoding/json" + "sort" "testing" qt "github.com/frankban/quicktest" @@ -98,11 +99,28 @@ func TestBySuffix(t *testing.T) { func TestGetFirstBySuffix(t *testing.T) { c := qt.New(t) - _, f, found := DefaultTypes.GetFirstBySuffix("xml") - c.Assert(found, qt.Equals, true) - c.Assert(f, qt.Equals, SuffixInfo{ - Suffix: "xml", - FullSuffix: ".xml"}) + + types := DefaultTypes + + // Issue #8406 + geoJSON := newMediaTypeWithMimeSuffix("application", "geo", "json", []string{"geojson", "gjson"}) + types = append(types, geoJSON) + sort.Sort(types) + + check := func(suffix string, expectedType Type) { + t, f, found := types.GetFirstBySuffix(suffix) + c.Assert(found, qt.Equals, true) + c.Assert(f, qt.Equals, SuffixInfo{ + Suffix: suffix, + FullSuffix: "." + suffix}) + c.Assert(t, qt.Equals, expectedType) + } + + check("js", JavascriptType) + check("json", JSONType) + check("geojson", geoJSON) + check("gjson", geoJSON) + } func TestFromTypeString(t *testing.T) { From 4713e509b678f5268225a07da0bf8f647c547e02 Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Tue, 20 Apr 2021 11:02:48 +0000 Subject: [PATCH 2/5] releaser: Add release notes for 0.82.1 [ci skip] --- temp/0.82.1-relnotes-ready.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 temp/0.82.1-relnotes-ready.md diff --git a/temp/0.82.1-relnotes-ready.md b/temp/0.82.1-relnotes-ready.md new file mode 100644 index 000000000..c2f9f082e --- /dev/null +++ b/temp/0.82.1-relnotes-ready.md @@ -0,0 +1,8 @@ + + +This is a bug-fix release with one important fix. + +* Regression in media type suffix lookup [6e9d2bf0](https://github.com/gohugoio/hugo/commit/6e9d2bf0c936900f8f676d485098755b3f463373) [@bep](https://github.com/bep) [#8406](https://github.com/gohugoio/hugo/issues/8406) + + + From f8b064f3c0282af94876d54567e068d833b442fd Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Tue, 20 Apr 2021 11:02:48 +0000 Subject: [PATCH 3/5] releaser: Bump versions for release of 0.82.1 [ci skip] --- common/hugo/version_current.go | 2 +- snap/snapcraft.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/hugo/version_current.go b/common/hugo/version_current.go index 640778655..e8059593f 100644 --- a/common/hugo/version_current.go +++ b/common/hugo/version_current.go @@ -17,6 +17,6 @@ package hugo // This should be the only one. var CurrentVersion = Version{ Number: 0.82, - PatchLevel: 0, + PatchLevel: 1, Suffix: "", } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index a0bceac70..f9c5a6d41 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: hugo -version: "0.82.0" +version: "0.82.1" summary: Fast and Flexible Static Site Generator description: | Hugo is a static HTML and CSS website generator written in Go. It is From 60618210b82bcec0cdf72cefb61f979326f5b785 Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Tue, 20 Apr 2021 11:02:48 +0000 Subject: [PATCH 4/5] releaser: Add release notes to /docs for release of 0.82.1 [ci skip] --- docs/content/en/news/0.82.1-relnotes/index.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/content/en/news/0.82.1-relnotes/index.md diff --git a/docs/content/en/news/0.82.1-relnotes/index.md b/docs/content/en/news/0.82.1-relnotes/index.md new file mode 100644 index 000000000..63781799a --- /dev/null +++ b/docs/content/en/news/0.82.1-relnotes/index.md @@ -0,0 +1,19 @@ + +--- +date: 2021-04-20 +title: "Hugo 0.82.1: A couple of Bug Fixes" +description: "This version fixes a couple of bugs introduced in 0.82.0." +categories: ["Releases"] +images: +- images/blog/hugo-bug-poster.png + +--- + + + +This is a bug-fix release with one important fix. + +* Regression in media type suffix lookup [6e9d2bf0](https://github.com/gohugoio/hugo/commit/6e9d2bf0c936900f8f676d485098755b3f463373) [@bep](https://github.com/bep) [#8406](https://github.com/gohugoio/hugo/issues/8406) + + + From fda3c4d1ed822452b521621898f4e4093bdfdafd Mon Sep 17 00:00:00 2001 From: hugoreleaser Date: Tue, 20 Apr 2021 11:44:34 +0000 Subject: [PATCH 5/5] releaser: Prepare repository for 0.83.0-DEV [ci skip] --- common/hugo/version_current.go | 6 +++--- snap/snapcraft.yaml | 4 ++-- temp/0.82.1-relnotes-ready.md | 8 -------- 3 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 temp/0.82.1-relnotes-ready.md diff --git a/common/hugo/version_current.go b/common/hugo/version_current.go index e8059593f..e6e042dd6 100644 --- a/common/hugo/version_current.go +++ b/common/hugo/version_current.go @@ -16,7 +16,7 @@ package hugo // CurrentVersion represents the current build version. // This should be the only one. var CurrentVersion = Version{ - Number: 0.82, - PatchLevel: 1, - Suffix: "", + Number: 0.83, + PatchLevel: 0, + Suffix: "-DEV", } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f9c5a6d41..d61f1d8b9 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,12 +1,12 @@ name: hugo -version: "0.82.1" +version: "0.83.0-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.82.1-relnotes-ready.md b/temp/0.82.1-relnotes-ready.md deleted file mode 100644 index c2f9f082e..000000000 --- a/temp/0.82.1-relnotes-ready.md +++ /dev/null @@ -1,8 +0,0 @@ - - -This is a bug-fix release with one important fix. - -* Regression in media type suffix lookup [6e9d2bf0](https://github.com/gohugoio/hugo/commit/6e9d2bf0c936900f8f676d485098755b3f463373) [@bep](https://github.com/bep) [#8406](https://github.com/gohugoio/hugo/issues/8406) - - -