Skip to content

Commit

Permalink
fix(internal/gapicgen): tidy all after dep bump (#4515)
Browse files Browse the repository at this point in the history
Fixes: #4434
  • Loading branch information
codyoss authored Jul 29, 2021
1 parent a52baa4 commit 9401be5
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
26 changes: 26 additions & 0 deletions internal/gapicgen/execv/gocmd/gocmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ package gocmd
import (
"errors"
"fmt"
"io/fs"
"log"
"os"
"os/exec"
"path/filepath"
"strings"

"cloud.google.com/go/internal/gapicgen/execv"
Expand All @@ -43,6 +45,30 @@ func ModTidy(dir string) error {
return c.Run()
}

// ModTidyAll tidies all mod files from the specified root directory.
func ModTidyAll(dir string) error {
log.Printf("[%s] finding all modules", dir)
var modDirs []string
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.Name() == "go.mod" {
modDirs = append(modDirs, filepath.Dir(path))
}
return nil
})
if err != nil {
return err
}
for _, modDir := range modDirs {
if err := ModTidy(modDir); err != nil {
return err
}
}
return nil
}

// ListModName finds a modules name for a given directory.
func ListModName(dir string) (string, error) {
modC := execv.Command("go", "list", "-m")
Expand Down
5 changes: 3 additions & 2 deletions internal/gapicgen/git/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,15 @@ set -ex
go get -d google.golang.org/api | true # We don't care that there's no files at root.
go get -d google.golang.org/genproto | true # We don't care that there's no files at root.
go mod tidy
`)
c.Dir = modDir
if err := c.Run(); err != nil {
return err
}
}
return nil

// Tidy all modules
return gocmd.ModTidyAll(tmpDir)
}

func addAndPushCode(tmpDir string) error {
Expand Down
2 changes: 1 addition & 1 deletion internal/generated/snippets/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ require (
cloud.google.com/go/pubsublite v0.88.0
cloud.google.com/go/spanner v0.88.0
google.golang.org/api v0.51.0
google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f
)
3 changes: 2 additions & 1 deletion internal/generated/snippets/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0 h1:VpRFBmFg/ol+rqJnkKLPjVebPNFbSxuj17B7bH1xMc8=
google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f h1:4m1jFN3fHeKo0UvpraW2ipO2O0rgp5w2ugXeggtecAk=
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
Expand Down
4 changes: 2 additions & 2 deletions internal/godocfx/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200827165113-ac2560b5e952/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0 h1:tcs4DyF9LYv8cynRAbX8JeBpuezJLaK6RfiATAsGwnY=
google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f h1:4m1jFN3fHeKo0UvpraW2ipO2O0rgp5w2ugXeggtecAk=
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down

0 comments on commit 9401be5

Please sign in to comment.