From bf50fd424991cc3d5205042947d57387d53416ec Mon Sep 17 00:00:00 2001 From: kcmvp Date: Sun, 16 Jun 2024 13:05:08 +0800 Subject: [PATCH] #117: print correct message when no need to update --- cmd/gbc/command/deps.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/gbc/command/deps.go b/cmd/gbc/command/deps.go index 3711ca1..9cab0a9 100644 --- a/cmd/gbc/command/deps.go +++ b/cmd/gbc/command/deps.go @@ -37,14 +37,19 @@ func upgradeAll() error { return !dependency.Indirect && dependency.Mod.Path == latest.A && dependency.Mod.Version != latest.B }) }) - args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string { - return latest.A - })) - cmd := exec.Command("go", args...) - if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil { - color.Red("failed to upgrade dependencies: %s", err.Error()) + if len(candidates) > 0 { + args := lo.Union([]string{"get", "-u"}, lo.Map(candidates, func(latest lo.Tuple2[string, string], _ int) string { + return latest.A + })) + cmd := exec.Command("go", args...) + if err := artifact.PtyCmdOutput(cmd, "upgrading dependencies ......", false, nil); err != nil { + color.Red("failed to upgrade dependencies: %s", err.Error()) + } + exec.Command("go", "mod", "tidy").CombinedOutput() //nolint + } else { + color.Green("all dependencies are latest") } - exec.Command("go", "mod", "tidy").CombinedOutput() //nolint + return nil }