File tree Expand file tree Collapse file tree 5 files changed +34
-6
lines changed
Expand file tree Collapse file tree 5 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,11 @@ package gocmd
1818import (
1919 "errors"
2020 "fmt"
21+ "io/fs"
2122 "log"
2223 "os"
2324 "os/exec"
25+ "path/filepath"
2426 "strings"
2527
2628 "cloud.google.com/go/internal/gapicgen/execv"
@@ -43,6 +45,30 @@ func ModTidy(dir string) error {
4345 return c .Run ()
4446}
4547
48+ // ModTidyAll tidies all mod files from the specified root directory.
49+ func ModTidyAll (dir string ) error {
50+ log .Printf ("[%s] finding all modules" , dir )
51+ var modDirs []string
52+ err := filepath .WalkDir (dir , func (path string , d fs.DirEntry , err error ) error {
53+ if err != nil {
54+ return err
55+ }
56+ if d .Name () == "go.mod" {
57+ modDirs = append (modDirs , filepath .Dir (path ))
58+ }
59+ return nil
60+ })
61+ if err != nil {
62+ return err
63+ }
64+ for _ , modDir := range modDirs {
65+ if err := ModTidy (modDir ); err != nil {
66+ return err
67+ }
68+ }
69+ return nil
70+ }
71+
4672// ListModName finds a modules name for a given directory.
4773func ListModName (dir string ) (string , error ) {
4874 modC := execv .Command ("go" , "list" , "-m" )
Original file line number Diff line number Diff line change @@ -410,14 +410,15 @@ set -ex
410410
411411go get -d google.golang.org/api | true # We don't care that there's no files at root.
412412go get -d google.golang.org/genproto | true # We don't care that there's no files at root.
413- go mod tidy
414413` )
415414 c .Dir = modDir
416415 if err := c .Run (); err != nil {
417416 return err
418417 }
419418 }
420- return nil
419+
420+ // Tidy all modules
421+ return gocmd .ModTidyAll (tmpDir )
421422}
422423
423424func addAndPushCode (tmpDir string ) error {
Original file line number Diff line number Diff line change @@ -32,5 +32,5 @@ require (
3232 cloud.google.com/go/pubsublite v0.88.0
3333 cloud.google.com/go/spanner v0.88.0
3434 google.golang.org/api v0.51.0
35- google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0
35+ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f
3636)
Original file line number Diff line number Diff line change @@ -147,8 +147,9 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG
147147google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 /go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo =
148148google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea /go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k =
149149google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0 /go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48 =
150- google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0 h1:VpRFBmFg/ol+rqJnkKLPjVebPNFbSxuj17B7bH1xMc8 =
151150google.golang.org/genproto v0.0.0-20210726200206-e7812ac95cc0 /go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48 =
151+ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f h1:4m1jFN3fHeKo0UvpraW2ipO2O0rgp5w2ugXeggtecAk =
152+ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f /go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48 =
152153google.golang.org/grpc v1.19.0 /go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c =
153154google.golang.org/grpc v1.23.0 /go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg =
154155google.golang.org/grpc v1.25.1 /go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY =
Original file line number Diff line number Diff line change @@ -306,8 +306,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
306306google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c /go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no =
307307google.golang.org/genproto v0.0.0-20200827165113-ac2560b5e952 /go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no =
308308google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea /go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k =
309- google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0 h1:tcs4DyF9LYv8cynRAbX8JeBpuezJLaK6RfiATAsGwnY =
310- google.golang.org/genproto v0.0.0-20210726143408-b02e89920bf0 /go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48 =
309+ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f h1:4m1jFN3fHeKo0UvpraW2ipO2O0rgp5w2ugXeggtecAk =
310+ google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f /go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48 =
311311google.golang.org/grpc v1.19.0 /go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c =
312312google.golang.org/grpc v1.20.1 /go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38 =
313313google.golang.org/grpc v1.21.1 /go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM =
You can’t perform that action at this time.
0 commit comments