mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
modules: Fix "hugo mod get -u" with no arguments
Fixes #6826 Closes #6825
This commit is contained in:
@@ -259,6 +259,28 @@ func (c *Client) Vendor() error {
|
||||
|
||||
// Get runs "go get" with the supplied arguments.
|
||||
func (c *Client) Get(args ...string) error {
|
||||
if len(args) == 0 || (len(args) == 1 && args[0] == "-u") {
|
||||
update := len(args) != 0
|
||||
|
||||
// We need to be explicit about the modules to get.
|
||||
for _, m := range c.moduleConfig.Imports {
|
||||
var args []string
|
||||
if update {
|
||||
args = []string{"-u"}
|
||||
}
|
||||
args = append(args, m.Path)
|
||||
if err := c.get(args...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.get(args...)
|
||||
}
|
||||
|
||||
func (c *Client) get(args ...string) error {
|
||||
if err := c.runGo(context.Background(), c.logger.Out, append([]string{"get"}, args...)...); err != nil {
|
||||
errors.Wrapf(err, "failed to get %q", args)
|
||||
}
|
||||
@@ -426,6 +448,11 @@ func (c *Client) runGo(
|
||||
return nil
|
||||
}
|
||||
|
||||
if strings.Contains(stderr.String(), "invalid version: unknown revision") {
|
||||
// See https://github.com/gohugoio/hugo/issues/6825
|
||||
c.logger.FEEDBACK.Println(`hugo: you need to manually edit go.mod to resolve the unknown revision.`)
|
||||
}
|
||||
|
||||
_, ok := err.(*exec.ExitError)
|
||||
if !ok {
|
||||
return errors.Errorf("failed to execute 'go %v': %s %T", args, err, err)
|
||||
|
Reference in New Issue
Block a user