mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fix so hugo get -u updates transitively
This commit is contained in:
parent
c23a0c4a0f
commit
de4e466036
3 changed files with 62 additions and 8 deletions
|
@ -318,6 +318,20 @@ func (c *Client) Get(args ...string) error {
|
||||||
patch := update && (args[0] == "-u=patch") //
|
patch := update && (args[0] == "-u=patch") //
|
||||||
|
|
||||||
// We need to be explicit about the modules to get.
|
// We need to be explicit about the modules to get.
|
||||||
|
var modules []string
|
||||||
|
// Update all active modules if the -u flag presents.
|
||||||
|
if update {
|
||||||
|
mc, coll := c.collect(true)
|
||||||
|
if coll.err != nil {
|
||||||
|
return coll.err
|
||||||
|
}
|
||||||
|
for _, m := range mc.AllModules {
|
||||||
|
if m.Owner() == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
modules = append(modules, m.Path())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for _, m := range c.moduleConfig.Imports {
|
for _, m := range c.moduleConfig.Imports {
|
||||||
if !isProbablyModule(m.Path) {
|
if !isProbablyModule(m.Path) {
|
||||||
// Skip themes/components stored below /themes etc.
|
// Skip themes/components stored below /themes etc.
|
||||||
|
@ -326,6 +340,11 @@ func (c *Client) Get(args ...string) error {
|
||||||
// "cannot find module providing ..." message.
|
// "cannot find module providing ..." message.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
modules = append(modules, m.Path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, m := range modules {
|
||||||
var args []string
|
var args []string
|
||||||
|
|
||||||
if update && !patch {
|
if update && !patch {
|
||||||
|
@ -333,7 +352,7 @@ func (c *Client) Get(args ...string) error {
|
||||||
} else if update && patch {
|
} else if update && patch {
|
||||||
args = append(args, "-u=patch")
|
args = append(args, "-u=patch")
|
||||||
}
|
}
|
||||||
args = append(args, m.Path)
|
args = append(args, m)
|
||||||
|
|
||||||
if err := c.get(args...); err != nil {
|
if err := c.get(args...); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
15
testscripts/commands/mod_get.txt
Normal file
15
testscripts/commands/mod_get.txt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
hugo mod get
|
||||||
|
stderr 'withhugotoml.*v1.1.0'
|
||||||
|
|
||||||
|
-- hugo.toml --
|
||||||
|
title = "Hugo Modules Test"
|
||||||
|
[module]
|
||||||
|
[[module.imports]]
|
||||||
|
path="github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml"
|
||||||
|
disable = true
|
||||||
|
[[module.imports]]
|
||||||
|
path="github.com/gohugoio/hugo-mod-integrationtests/withhugotoml"
|
||||||
|
-- go.mod --
|
||||||
|
module foo
|
||||||
|
go 1.20
|
||||||
|
|
20
testscripts/commands/mod_get_u.txt
Normal file
20
testscripts/commands/mod_get_u.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
hugo mod get -u
|
||||||
|
hugo mod graph
|
||||||
|
stdout 'commonmod@v1.0.1.*commonmod2@v1.0.2'
|
||||||
|
|
||||||
|
-- hugo.toml --
|
||||||
|
title = "Hugo Modules Update Test"
|
||||||
|
[module]
|
||||||
|
[[module.imports]]
|
||||||
|
path="github.com/gohugoio/hugo-mod-integrationtests/withconfigtoml"
|
||||||
|
disable = true
|
||||||
|
[[module.imports]]
|
||||||
|
path="github.com/gohugoio/hugo-mod-integrationtests/withhugotoml"
|
||||||
|
-- go.mod --
|
||||||
|
module foo
|
||||||
|
go 1.20
|
||||||
|
require (
|
||||||
|
github.com/gohugoio/hugo-mod-integrationtests/withhugotoml v1.1.0 // indirect
|
||||||
|
github.com/gohugoio/hugo-mod-integrationtests/commonmod v0.0.0-20230823103305-919cefe8a425 // indirect
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue