mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
modules: Add support for direct version module imports in hugo.toml
Fixes #13964
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
hugo mod graph
|
||||
stdout 'foo'
|
||||
grep 'github.com/bep/hugo-mod-nop v1.0.0 h1:NRDMRPCD\+4dw5K8XvaZURvZJCfBMCifkRe6C6x6W4II=' hugo.direct.sum
|
||||
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[[module.imports]]
|
||||
path = "github.com/bep/hugo-mod-nop"
|
||||
version = "v1.0.0"
|
||||
-- layouts/all.html --
|
||||
All.
|
||||
-- go.mod --
|
||||
module foo
|
||||
|
||||
go 1.24.0
|
||||
@@ -0,0 +1,16 @@
|
||||
! hugo
|
||||
stderr 'checksum mismatch'
|
||||
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[[module.imports]]
|
||||
path = "github.com/bep/hugo-mod-nop"
|
||||
version = "v1.0.0"
|
||||
-- layouts/all.html --
|
||||
All.
|
||||
-- go.mod --
|
||||
module foo
|
||||
|
||||
go 1.24.0
|
||||
-- hugo.direct.sum --
|
||||
github.com/bep/hugo-mod-nop v1.0.0 h1:NRDMRPCD+4dw5K8XvaZURvZJCfBMCifkRe6C6x6W4Ix=
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
# We're not testing Go's security here, so we just edit the go.sum and verifies that the build fails.
|
||||
|
||||
! hugo
|
||||
stderr 'checksum mismatch'
|
||||
|
||||
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[[module.imports]]
|
||||
path = "github.com/bep/hugo-mod-nop"
|
||||
-- layouts/all.html --
|
||||
All.
|
||||
-- go.mod --
|
||||
module foo
|
||||
|
||||
go 1.24.0
|
||||
|
||||
require github.com/bep/hugo-mod-nop v1.0.0 // indirect
|
||||
-- go.sum --
|
||||
github.com/bep/hugo-mod-nop v1.0.0 h1:NRDMRPCD+4dw5K8XvaZURvZJCfBMCifkRe6C6x6W4II=
|
||||
github.com/bep/hugo-mod-nop v1.0.0/go.mod h1:6cqjOCVJHP6+aQ+5IYvaS9j8BfIVksAct4xzl9OnmIX=
|
||||
@@ -0,0 +1,102 @@
|
||||
dostounix golden/vendor.txt
|
||||
|
||||
hugo mod vendor
|
||||
cmp _vendor/modules.txt golden/vendor.txt
|
||||
lsr _vendor
|
||||
stdout 'github.com/bep/hugo-mod-misc/dummy-content@%3C%3Dv0.1.0/config.toml'
|
||||
stdout 'github.com/bep/hugo-mod-misc/dummy-content@v0.2.0/config.toml'
|
||||
stdout 'github.com/bep/hugo-mod-misc/dummy-content@v0.2.0/content/blog/music/all-of-me/index.md'
|
||||
stdout 'github.com/bep/hugo-mod-misc/dummy-content@v0.2.0/content/blog/music/blue-bossa/index.md'
|
||||
stdout 'github.com/bep/hugo-mod-misc/dummy-content@%3C%3Dv0.1.0/content/blog/music/all-of-me/index.md'
|
||||
! stdout 'github.com/bep/hugo-mod-misc/dummy-content@%3C%3Dv0.1.0/content/blog/music/blue-bossa/index.md' # not mounted
|
||||
|
||||
hugo mod graph
|
||||
stdout 'project github.com/bep/hugo-mod-misc/dummy-content@v0.2.0'
|
||||
stdout 'project github.com/bep/hugo-mod-misc/dummy-content@v0.1.0'
|
||||
|
||||
hugo config mounts
|
||||
[unix] cmpenv stdout golden/mounts.json
|
||||
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[[module.imports]]
|
||||
path = "github.com/bep/hugo-mod-misc/dummy-content"
|
||||
version = "v0.2.0"
|
||||
[[module.imports]]
|
||||
path = "github.com/bep/hugo-mod-misc/dummy-content"
|
||||
version = "<=v0.1.0"
|
||||
[[module.imports.mounts]]
|
||||
source = "content/blog/music/all-of-me"
|
||||
target = "content/all"
|
||||
-- layouts/all.html --
|
||||
Title: {{ .Title }}|Summary: {{ .Summary }}|
|
||||
Deps: {{ range hugo.Deps}}{{ printf "%s@%s" .Path .Version }}|{{ end }}$
|
||||
|
||||
|
||||
-- golden/vendor.txt --
|
||||
# github.com/bep/hugo-mod-misc/dummy-content@v0.2.0 v0.2.0
|
||||
# github.com/bep/hugo-mod-misc/dummy-content@%3C%3Dv0.1.0 v0.1.0
|
||||
-- golden/mounts.json --
|
||||
{
|
||||
"path": "project",
|
||||
"version": "",
|
||||
"time": "0001-01-01T00:00:00Z",
|
||||
"owner": "",
|
||||
"dir": "$WORK",
|
||||
"mounts": [
|
||||
{
|
||||
"source": "content",
|
||||
"target": "content"
|
||||
},
|
||||
{
|
||||
"source": "data",
|
||||
"target": "data"
|
||||
},
|
||||
{
|
||||
"source": "layouts",
|
||||
"target": "layouts"
|
||||
},
|
||||
{
|
||||
"source": "i18n",
|
||||
"target": "i18n"
|
||||
},
|
||||
{
|
||||
"source": "archetypes",
|
||||
"target": "archetypes"
|
||||
},
|
||||
{
|
||||
"source": "assets",
|
||||
"target": "assets"
|
||||
},
|
||||
{
|
||||
"source": "static",
|
||||
"target": "static"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"path": "github.com/bep/hugo-mod-misc/dummy-content",
|
||||
"version": "v0.2.0",
|
||||
"time": "0001-01-01T00:00:00Z",
|
||||
"owner": "project",
|
||||
"dir": "$WORK/_vendor/github.com/bep/hugo-mod-misc/dummy-content@v0.2.0/",
|
||||
"mounts": [
|
||||
{
|
||||
"source": "content",
|
||||
"target": "content"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"path": "github.com/bep/hugo-mod-misc/dummy-content",
|
||||
"version": "v0.1.0",
|
||||
"time": "0001-01-01T00:00:00Z",
|
||||
"owner": "project",
|
||||
"dir": "$WORK/_vendor/github.com/bep/hugo-mod-misc/dummy-content@%3C%3Dv0.1.0/",
|
||||
"mounts": [
|
||||
{
|
||||
"source": "content/blog/music/all-of-me",
|
||||
"target": "content/all"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user