Repository: gohugoio/hugo (language: go)

Issue:
Support '-u=patch' in hugo mod get
The go module system supports updating all modules to the latest patch version with the following command:

`go get -u=patch`

The equivalent hugo command (`hugo mod get -u=patch`) doesn't work and outputs the following message on my hugo project:

`go get: no package in current directory`

A quick look at the code shows that there is special handling for `-u` with no additional arguments here:  https://github.com/gohugoio/hugo/blob/82c33c7105a4d0c0e097f0d074c02995cb2b4d20/modules/client.go#L307

It seems (and I'm no expert) that this code could be updated fairly easily to also support `-u=patch`.

Thanks.
Support '-u=patch' in hugo mod get
The go module system supports updating all modules to the latest patch version with the following command:

`go get -u=patch`

The equivalent hugo command (`hugo mod get -u=patch`) doesn't work and outputs the following message on my hugo project:

`go get: no package in current directory`

A quick look at the code shows that there is special handling for `-u` with no additional arguments here:  https://github.com/gohugoio/hugo/blob/82c33c7105a4d0c0e097f0d074c02995cb2b4d20/modules/client.go#L307

It seems (and I'm no expert) that this code could be updated fairly easily to also support `-u=patch`.

Thanks.


Discussion / hints:

Fix patch:
diff --git a/modules/client.go b/modules/client.go
index fe0abc46256..eab871d01b0 100644
--- a/modules/client.go
+++ b/modules/client.go
@@ -305,8 +305,9 @@ 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") {
+	if len(args) == 0 || (len(args) == 1 && strings.Contains(args[0], "-u")) {
 		update := len(args) != 0
+		patch := update && (args[0] == "-u=patch") //
 
 		// We need to be explicit about the modules to get.
 		for _, m := range c.moduleConfig.Imports {
@@ -318,10 +319,14 @@ func (c *Client) Get(args ...string) error {
 				continue
 			}
 			var args []string
-			if update {
+
+			if update && !patch {
 				args = append(args, "-u")
+			} else if update && patch {
+				args = append(args, "-u=patch")
 			}
 			args = append(args, m.Path)
+
 			if err := c.get(args...); err != nil {
 				return err
 			}


Test patch: