mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-19 07:42:48 +00:00
Compare commits
5 commits
9d070a494c
...
825e85260a
Author | SHA1 | Date | |
---|---|---|---|
825e85260a | |||
c46d603a02 | |||
69ede10edc | |||
bb59a7ed97 | |||
fe38d73044 |
|
@ -23,11 +23,9 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bep/logg"
|
||||
"github.com/gohugoio/hugo/cache/dynacache"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
|
@ -47,7 +45,6 @@ import (
|
|||
"github.com/gohugoio/hugo/resources/page"
|
||||
"github.com/gohugoio/hugo/resources/page/siteidentities"
|
||||
"github.com/gohugoio/hugo/resources/postpub"
|
||||
"github.com/gohugoio/hugo/resources/resource"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
|
||||
|
@ -764,48 +761,8 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
|
|||
}
|
||||
}
|
||||
case files.ComponentFolderAssets:
|
||||
p := pathInfo.Path()
|
||||
logger.Println("Asset changed", p)
|
||||
|
||||
var matches []any
|
||||
var mu sync.Mutex
|
||||
|
||||
h.MemCache.ClearMatching(
|
||||
func(k string, pm dynacache.PartitionManager) bool {
|
||||
// Avoid going through everything.
|
||||
return strings.HasPrefix(k, "/res")
|
||||
},
|
||||
func(k, v any) bool {
|
||||
if strings.Contains(k.(string), p) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
switch vv := v.(type) {
|
||||
case resource.Resources:
|
||||
// GetMatch/Match.
|
||||
for _, r := range vv {
|
||||
matches = append(matches, r)
|
||||
}
|
||||
return true
|
||||
default:
|
||||
matches = append(matches, vv)
|
||||
return true
|
||||
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
var hasID bool
|
||||
for _, r := range matches {
|
||||
identity.WalkIdentitiesShallow(r, func(level int, rid identity.Identity) bool {
|
||||
hasID = true
|
||||
changes = append(changes, rid)
|
||||
return false
|
||||
})
|
||||
}
|
||||
if !hasID {
|
||||
changes = append(changes, pathInfo)
|
||||
}
|
||||
logger.Println("Asset changed", pathInfo.Path())
|
||||
changes = append(changes, pathInfo)
|
||||
case files.ComponentFolderData:
|
||||
logger.Println("Data changed", pathInfo.Path())
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Release env.
|
||||
# These will be replaced by script before release.
|
||||
HUGORELEASER_TAG=v0.125.5
|
||||
HUGORELEASER_COMMITISH=c8b9f9f81c375f5b391e61bae711ee63fc76c1fd
|
||||
HUGORELEASER_TAG=v0.125.6
|
||||
HUGORELEASER_COMMITISH=69ede10edcd539380914bbee58d4d32953dd8b43
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ package pageparser
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
@ -40,7 +41,8 @@ type pageLexer struct {
|
|||
cfg Config
|
||||
|
||||
// The summary divider to look for.
|
||||
summaryDivider []byte
|
||||
summaryDivider []byte
|
||||
summaryDividerReg *regexp.Regexp
|
||||
// Set when we have parsed any summary divider
|
||||
summaryDividerChecked bool
|
||||
|
||||
|
@ -96,6 +98,7 @@ func (l *pageLexer) run() *pageLexer {
|
|||
var (
|
||||
byteOrderMark = '\ufeff'
|
||||
summaryDivider = []byte("<!--more-->")
|
||||
summaryDividerReg = regexp.MustCompile("(?m)^<!--more-->")
|
||||
summaryDividerOrg = []byte("# more")
|
||||
delimTOML = []byte("+++")
|
||||
delimYAML = []byte("---")
|
||||
|
@ -333,10 +336,11 @@ func createSectionHandlers(l *pageLexer) *sectionHandlers {
|
|||
summaryDividerHandler := §ionHandler{
|
||||
l: l,
|
||||
skipFunc: func(l *pageLexer) int {
|
||||
if l.summaryDividerChecked || l.summaryDivider == nil {
|
||||
if l.summaryDividerChecked || l.summaryDividerReg == nil {
|
||||
return -1
|
||||
}
|
||||
return l.index(l.summaryDivider)
|
||||
return l.regexIndex(l.summaryDividerReg)
|
||||
//return l.index(l.summaryDivider)
|
||||
},
|
||||
lexFunc: func(origin stateFunc, l *pageLexer) (stateFunc, bool) {
|
||||
if !l.hasPrefix(l.summaryDivider) {
|
||||
|
@ -460,6 +464,14 @@ func (l *pageLexer) index(sep []byte) int {
|
|||
return bytes.Index(l.input[l.pos:], sep)
|
||||
}
|
||||
|
||||
func (l *pageLexer) regexIndex(re *regexp.Regexp) int {
|
||||
pos := re.FindIndex(l.input[l.pos:])
|
||||
if pos == nil {
|
||||
return -1
|
||||
}
|
||||
return pos[0]
|
||||
}
|
||||
|
||||
func (l *pageLexer) hasPrefix(prefix []byte) bool {
|
||||
return bytes.HasPrefix(l.input[l.pos:], prefix)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ package pageparser
|
|||
|
||||
func lexIntroSection(l *pageLexer) stateFunc {
|
||||
l.summaryDivider = summaryDivider
|
||||
l.summaryDividerReg = summaryDividerReg
|
||||
|
||||
LOOP:
|
||||
for {
|
||||
|
@ -94,6 +95,7 @@ func lexFrontMatterOrgMode(l *pageLexer) stateFunc {
|
|||
*/
|
||||
|
||||
l.summaryDivider = summaryDividerOrg
|
||||
l.summaryDividerReg = summaryDividerReg
|
||||
|
||||
l.backup()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2021 The Hugo Authors. All rights reserved.
|
||||
// Copyright 2024 The Hugo Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -328,6 +328,7 @@ Styles: {{ $r.RelPermalink }}
|
|||
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
|
||||
}
|
||||
|
||||
// Issue #1239.
|
||||
func TestRebuildAssetGetMatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !scss.Supports() {
|
||||
|
@ -358,3 +359,61 @@ T1: {{ $r.Content }}
|
|||
|
||||
b.AssertFileContent("public/index.html", `color: blue`)
|
||||
}
|
||||
|
||||
func TestRebuildAssetMatchIssue12456(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !scss.Supports() {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
disableLiveReload = true
|
||||
-- assets/a.scss --
|
||||
h1 {
|
||||
color: red;
|
||||
}
|
||||
-- assets/dir/b.scss --
|
||||
h2 {
|
||||
color: blue;
|
||||
}
|
||||
-- assets/dir/c.scss --
|
||||
h3 {
|
||||
color: green;
|
||||
}
|
||||
-- layouts/index.html --
|
||||
{{ $a := slice (resources.Get "a.scss") }}
|
||||
{{ $b := resources.Match "dir/*.scss" }}
|
||||
|
||||
{{/* Add styles in a specific order. */}}
|
||||
{{ $styles := slice $a $b }}
|
||||
|
||||
{{ $stylesheets := slice }}
|
||||
{{ range $styles }}
|
||||
{{ $stylesheets = $stylesheets | collections.Append . }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ range $stylesheets }}
|
||||
{{ with . | resources.ToCSS | fingerprint }}
|
||||
<link as="style" href="{{ .RelPermalink }}" rel="preload stylesheet">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
`
|
||||
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
NeedsOsFS: true,
|
||||
Running: true,
|
||||
// LogLevel: logg.LevelTrace,
|
||||
}).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", `b.60a9f3bdc189ee8a857afd5b7e1b93ad1644de0873761a7c9bc84f781a821942.css`)
|
||||
|
||||
b.EditFiles("assets/dir/b.scss", `h2 { color: orange; }`).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", `b.46b2d77c7ffe37ee191678f72df991ecb1319f849957151654362f09b0ef467f.css`)
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ var (
|
|||
_ resource.ReadSeekCloserResource = (*resourceAdapter)(nil)
|
||||
_ resource.Resource = (*resourceAdapter)(nil)
|
||||
_ resource.Staler = (*resourceAdapterInner)(nil)
|
||||
_ identity.IdentityGroupProvider = (*resourceAdapterInner)(nil)
|
||||
_ resource.Source = (*resourceAdapter)(nil)
|
||||
_ resource.Identifier = (*resourceAdapter)(nil)
|
||||
_ resource.ResourceNameTitleProvider = (*resourceAdapter)(nil)
|
||||
|
@ -657,6 +658,10 @@ type resourceAdapterInner struct {
|
|||
*publishOnce
|
||||
}
|
||||
|
||||
func (r *resourceAdapterInner) GetIdentityGroup() identity.Identity {
|
||||
return r.target.GetIdentityGroup()
|
||||
}
|
||||
|
||||
func (r *resourceAdapterInner) StaleVersion() uint32 {
|
||||
// Both of these are incremented on change.
|
||||
return r.Staler.StaleVersion() + r.target.StaleVersion()
|
||||
|
|
Loading…
Reference in a new issue