Skip to content

Commit 66281dd

Browse files
authored
Merge pull request #119 from kcmvp/upgrade-deps
#117: print correct message when no need to update
2 parents 80e5376 + bf50fd4 commit 66281dd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

cmd/gbc/command/deps.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,19 @@ func upgradeAll() error {
3737
return !dependency.Indirect && dependency.Mod.Path == latest.A && dependency.Mod.Version != latest.B
3838
})
3939
})
40-
args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string {
41-
return latest.A
42-
}))
43-
cmd := exec.Command("go", args...)
44-
if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil {
45-
color.Red("failed to upgrade dependencies: %s", err.Error())
40+
if len(candidates) > 0 {
41+
args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string {
42+
return latest.A
43+
}))
44+
cmd := exec.Command("go", args...)
45+
if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil {
46+
color.Red("failed to upgrade dependencies: %s", err.Error())
47+
}
48+
exec.Command("go", "mod", "tidy").CombinedOutput() //nolint
49+
} else {
50+
color.Green("all dependencies are latest")
4651
}
47-
exec.Command("go", "mod", "tidy").CombinedOutput() //nolint
52+
4853
return nil
4954
}
5055

0 commit comments

Comments
 (0)