Compare commits

...

11 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen d95c4eca3d releaser: Update /docs to 0.24.1 [ci skip] 2017-06-24 10:26:30 +02:00
Bjørn Erik Pedersen 63a51dc196 releaser: Bump versions for release of 0.24.1
[ci skip]
2017-06-24 10:24:54 +02:00
Bjørn Erik Pedersen 93a6099fb3 releaser: Add release notes draft for 0.24.1
[ci skip]
2017-06-24 10:24:40 +02:00
Bjørn Erik Pedersen 32f074075d helpers: Add temporary workaround for next patch version calculation 2017-06-24 10:20:02 +02:00
Bjørn Erik Pedersen 1f78024ecb releaser: One more fix 2017-06-24 09:51:10 +02:00
Bjørn Erik Pedersen ea3bd10c74 releaser: Improve docs submodule handling
Still not optimal.
2017-06-24 09:51:10 +02:00
Bjørn Erik Pedersen 0744f81ec0 vendor: Fix +-timezones in TOML
Fixes #29
2017-06-24 09:28:11 +02:00
Bjørn Erik Pedersen b63e4ee198 create: Preserve shortcodes in archetype templates
Fixes #3623
2017-06-24 09:28:11 +02:00
Bjørn Erik Pedersen bfa336d961 commands: Create default archetype on new site
See #3626
2017-06-24 09:28:11 +02:00
Bjørn Erik Pedersen 4294dd8d9d create: Fix archetype regression when no archetype file
Fixes #3626
2017-06-24 09:28:11 +02:00
Anthony Fok 4c3fa73a00 releaser: Fix typo, change "relase" to "release" 2017-06-24 09:28:11 +02:00
12 changed files with 123 additions and 42 deletions
+7 -2
View File
@@ -152,10 +152,11 @@ func NewContent(cmd *cobra.Command, args []string) error {
}
func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
archeTypePath := filepath.Join(basepath, "archetypes")
dirs := []string{
filepath.Join(basepath, "layouts"),
filepath.Join(basepath, "content"),
filepath.Join(basepath, "archetypes"),
archeTypePath,
filepath.Join(basepath, "static"),
filepath.Join(basepath, "data"),
filepath.Join(basepath, "themes"),
@@ -190,6 +191,10 @@ func doNewSite(fs *hugofs.Fs, basepath string, force bool) error {
createConfig(fs, basepath, configFormat)
// Create a defaul archetype file.
helpers.SafeWriteToDisk(filepath.Join(archeTypePath, "default.md"),
strings.NewReader(create.ArchetypeTemplateTemplate), fs.Source)
jww.FEEDBACK.Printf("Congratulations! Your new Hugo site is created in %s.\n\n", basepath)
jww.FEEDBACK.Println(nextStepsText())
@@ -342,7 +347,7 @@ description = ""
homepage = "http://siteforthistheme.com/"
tags = []
features = []
min_version = "0.24"
min_version = "0.24.1"
[author]
name = ""
+11 -7
View File
@@ -36,15 +36,19 @@ func NewContent(
archetypeFilename := findArchetype(ps, kind, ext)
f, err := ps.Fs.Source.Open(archetypeFilename)
if err != nil {
return err
}
defer f.Close()
// Building the sites can be expensive, so only do it if really needed.
siteUsed := false
if helpers.ReaderContains(f, []byte(".Site")) {
siteUsed = true
if archetypeFilename != "" {
f, err := ps.Fs.Source.Open(archetypeFilename)
if err != nil {
return err
}
defer f.Close()
if helpers.ReaderContains(f, []byte(".Site")) {
siteUsed = true
}
}
s, err := siteFactory(targetPath, siteUsed)
+29 -8
View File
@@ -16,6 +16,7 @@ package create
import (
"bytes"
"fmt"
"strings"
"time"
"github.com/gohugoio/hugo/helpers"
@@ -48,11 +49,27 @@ type ArchetypeFileData struct {
}
const (
archetypeTemplateTemplate = `+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = {{ .Date }}
draft = true
+++`
ArchetypeTemplateTemplate = `---
title: "{{ replace .TranslationBaseName "-" " " | title }}"
date: {{ .Date }}
draft: true
---
`
)
var (
archetypeShortcodeReplacementsPre = strings.NewReplacer(
"{{<", "{x{<",
"{{%", "{x{%",
">}}", ">}x}",
"%}}", "%}x}")
archetypeShortcodeReplacementsPost = strings.NewReplacer(
"{x{<", "{{<",
"{x{%", "{{%",
">}x}", ">}}",
"%}x}", "%}}")
)
func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFilename string) ([]byte, error) {
@@ -75,7 +92,7 @@ func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFile
if archetypeFilename == "" {
// TODO(bep) archetype revive the issue about wrong tpl funcs arg order
archetypeTemplate = []byte(archetypeTemplateTemplate)
archetypeTemplate = []byte(ArchetypeTemplateTemplate)
} else {
archetypeTemplate, err = afero.ReadFile(s.Fs.Source, archetypeFilename)
if err != nil {
@@ -84,6 +101,10 @@ func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFile
}
// The archetype template may contain shortcodes, and these does not play well
// with the Go templates. Need to set some temporary delimiters.
archetypeTemplate = []byte(archetypeShortcodeReplacementsPre.Replace(string(archetypeTemplate)))
// Reuse the Hugo template setup to get the template funcs properly set up.
templateHandler := s.Deps.Tmpl.(tpl.TemplateHandler)
templateName := "_text/" + helpers.Filename(archetypeFilename)
@@ -98,14 +119,14 @@ func executeArcheTypeAsTemplate(s *hugolib.Site, kind, targetPath, archetypeFile
return nil, fmt.Errorf("Failed to process archetype file %q: %s", archetypeFilename, err)
}
archetypeContent = buff.Bytes()
archetypeContent = []byte(archetypeShortcodeReplacementsPost.Replace(buff.String()))
if !bytes.Contains(archetypeContent, []byte("date")) || !bytes.Contains(archetypeContent, []byte("title")) {
// TODO(bep) remove some time in the future.
s.Log.FEEDBACK.Println(fmt.Sprintf(`WARNING: date and/or title missing from archetype file %q.
From Hugo 0.24 this must be provided in the archetype file itself, if needed. Example:
%s
`, archetypeFilename, archetypeTemplateTemplate))
`, archetypeFilename, ArchetypeTemplateTemplate))
}
+25 -2
View File
@@ -46,9 +46,14 @@ func TestNewContent(t *testing.T) {
{"post", "post/sample-1.md", []string{`title = "Post Arch title"`, `test = "test1"`, "date = \"2015-01-12T19:20:04-07:00\""}},
{"post", "post/org-1.org", []string{`#+title: ORG-1`}},
{"emptydate", "post/sample-ed.md", []string{`title = "Empty Date Arch title"`, `test = "test1"`}},
{"stump", "stump/sample-2.md", []string{`title = "Sample 2"`}}, // no archetype file
{"", "sample-3.md", []string{`title = "Sample 3"`}}, // no archetype
{"stump", "stump/sample-2.md", []string{`title: "Sample 2"`}}, // no archetype file
{"", "sample-3.md", []string{`title: "Sample 3"`}}, // no archetype
{"product", "product/sample-4.md", []string{`title = "SAMPLE-4"`}}, // empty archetype front matter
{"shortcodes", "shortcodes/go.md", []string{
`title = "GO"`,
"{{< myshortcode >}}",
"{{% myshortcode %}}",
"{{</* comment */>}}\n{{%/* comment */%}}"}}, // shortcodes
}
for _, c := range cases {
@@ -126,6 +131,24 @@ title = "{{ .BaseFileName | upper }}"
path: filepath.Join("archetypes", "emptydate.md"),
content: "+++\ndate =\"\"\ntitle = \"Empty Date Arch title\"\ntest = \"test1\"\n+++\n",
},
// #3623x
{
path: filepath.Join("archetypes", "shortcodes.md"),
content: `+++
title = "{{ .BaseFileName | upper }}"
+++
{{< myshortcode >}}
Some text.
{{% myshortcode %}}
{{</* comment */>}}
{{%/* comment */%}}
`,
},
} {
f, err := fs.Source.Create(v.path)
if err != nil {
+1 -1
Submodule docs updated: 5306e086f7...0d754d851c
+4 -2
View File
@@ -56,14 +56,16 @@ func (v HugoVersion) Prev() HugoVersion {
// NextPatchLevel returns the next patch/bugfix Hugo version.
// This will be a patch increment on the previous Hugo version.
func (v HugoVersion) NextPatchLevel(level int) HugoVersion {
return HugoVersion{Number: v.Number - 0.01, PatchLevel: level}
// return HugoVersion{Number: v.Number - 0.01, PatchLevel: level}
// TODO(bep) FIX me.
return HugoVersion{Number: v.Number, PatchLevel: level}
}
// CurrentHugoVersion represents the current build version.
// This should be the only one.
var CurrentHugoVersion = HugoVersion{
Number: 0.24,
PatchLevel: 0,
PatchLevel: 1,
Suffix: "",
}
+1 -1
View File
@@ -247,7 +247,7 @@ func getGitInfosBefore(ref, tag string, remote bool) (gitInfos, error) {
}
// Ignore autogenerated commits etc. in change log. This is a regexp.
const ignoredCommits = "release:|vendor:|snapcraft:"
const ignoredCommits = "releaser?:|snapcraft:"
func gitLogBefore(ref, tag string) (string, error) {
var prevTag string
+5 -5
View File
@@ -39,7 +39,7 @@ const (
{{ if eq (len .All) 1 }}
This is a bug-fix release with one important fix.
{{ else }}
This is a bug-fix relase with a couple of important fixes.
This is a bug-fix release with a couple of important fixes.
{{ end }}
{{ else }}
This release represents **{{ len .All }} contributions by {{ len $contribsPerAuthor }} contributors** to the main Hugo code base.
@@ -185,16 +185,16 @@ func writeReleaseNotesToTmpFile(version string, infos gitInfos) (string, error)
return f.Name(), nil
}
func getRelaseNotesDocsTempDirAndName(version string) (string, string) {
func getReleaseNotesDocsTempDirAndName(version string) (string, string) {
return hugoFilepath("temp"), fmt.Sprintf("%s-relnotes.md", version)
}
func getRelaseNotesDocsTempFilename(version string) string {
return filepath.Join(getRelaseNotesDocsTempDirAndName(version))
func getReleaseNotesDocsTempFilename(version string) string {
return filepath.Join(getReleaseNotesDocsTempDirAndName(version))
}
func writeReleaseNotesToTemp(version string, infos gitInfos) (string, error) {
docsTempPath, name := getRelaseNotesDocsTempDirAndName(version)
docsTempPath, name := getReleaseNotesDocsTempDirAndName(version)
os.Mkdir(docsTempPath, os.ModePerm)
f, err := os.Create(filepath.Join(docsTempPath, name))
+19 -10
View File
@@ -33,7 +33,7 @@ const commitPrefix = "releaser:"
type ReleaseHandler struct {
patch int
// If set, we do the relases in 3 steps:
// If set, we do the releases in 3 steps:
// 1: Create and write a draft release notes
// 2: Prepare files for new version.
// 3: Release
@@ -142,13 +142,22 @@ func (r *ReleaseHandler) Run() error {
}
if r.shouldPrepareVersions() {
// Make sure the docs submodule is up to date.
if _, err := git("submodule", "update", "--remote", "--merge"); err != nil {
return err
}
// TODO(bep) the above may not have changed anything.
if _, err := git("commit", "-a", "-m", fmt.Sprintf("%s Update /docs [ci skip]", commitPrefix)); err != nil {
return err
if newVersion.PatchLevel == 0 {
// Make sure the docs submodule is up to date.
// TODO(bep) improve this. Maybe it was not such a good idea to do
// this in the sobmodule directly.
if _, err := git("submodule", "update", "--init"); err != nil {
return err
}
//git submodule update
if _, err := git("submodule", "update", "--remote", "--merge"); err != nil {
return err
}
// TODO(bep) the above may not have changed anything.
if _, err := git("commit", "-a", "-m", fmt.Sprintf("%s Update /docs [ci skip]", commitPrefix)); err != nil {
return err
}
}
if err := bumpVersions(newVersion); err != nil {
@@ -167,7 +176,7 @@ func (r *ReleaseHandler) Run() error {
return nil
}
releaseNotesFile := getRelaseNotesDocsTempFilename(version)
releaseNotesFile := getReleaseNotesDocsTempFilename(version)
// Write the release notes to the docs site as well.
docFile, err := writeReleaseNotesToDocs(version, releaseNotesFile)
@@ -178,7 +187,7 @@ func (r *ReleaseHandler) Run() error {
if _, err := git("-C", "docs", "add", docFile); err != nil {
return err
}
if _, err := git("-C", "docs", "commit", "-m", fmt.Sprintf("%s Add relase notes to /docs for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil {
if _, err := git("-C", "docs", "commit", "-m", fmt.Sprintf("%s Add release notes to /docs for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil {
return err
}
+1 -1
View File
@@ -1,5 +1,5 @@
name: hugo
version: "0.24"
version: "0.24.1"
summary: Fast and Flexible Static Site Generator
description: |
Hugo is a static HTML and CSS website generator written in Go. It is
+17
View File
@@ -0,0 +1,17 @@
This release fixes some important **archetype-related regressions** from the recent Hugo 0.24-relase.
## Fixes
* Fix archetype regression when no archetype file [4294dd8d](https://github.com/gohugoio/hugo/commit/4294dd8d9d22bd8107b7904d5389967da1f83f27) [@bep](https://github.com/bep) [#3626](https://github.com/gohugoio/hugo/issues/3626)
* Preserve shortcodes in archetype templates [b63e4ee1](https://github.com/gohugoio/hugo/commit/b63e4ee198c875b73a6a9af6bb809589785ed589) [@bep](https://github.com/bep) [#3623](https://github.com/gohugoio/hugo/issues/3623)
* Fix +-timezones in TOML [0744f81e](https://github.com/gohugoio/hugo/commit/0744f81ec00bb8888f59d6c8b5f57096e07e70b1) [@bep](https://github.com/bep) [#29](https://github.com/gohugoio/hugo/issues/29)
## Enhancements
* Create default archetype on new site [bfa336d9](https://github.com/gohugoio/hugo/commit/bfa336d96173377b9bbe2298dbd101f6a718c174) [@bep](https://github.com/bep) [#3626](https://github.com/gohugoio/hugo/issues/3626)
+3 -3
View File
@@ -3,10 +3,10 @@
"ignore": "test",
"package": [
{
"checksumSHA1": "pPH/BoINXxzYDObljpsGZbysMrw=",
"checksumSHA1": "fEgW0LDkuhB+99rGbe1upZnGK6I=",
"path": "github.com/BurntSushi/toml",
"revision": "b26d9c308763d68093482582cea63d69be07a0f0",
"revisionTime": "2017-03-28T06:15:53Z"
"revision": "8fb9fdc4f82fd3495b9086c911b86cc3d50cb7ab",
"revisionTime": "2017-06-23T11:17:45Z"
},
{
"checksumSHA1": "NX4v3cbkXAJxFlrncqT9yEUBuoA=",