From fa101cad931fe82e8aada278928f9d9f05aca4d8 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Fri, 22 Jul 2022 22:10:38 +0700 Subject: [PATCH] chore: ignore auto commit when dry run --- internal/cli/action_run.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/cli/action_run.go b/internal/cli/action_run.go index 959d76d..4fc107a 100644 --- a/internal/cli/action_run.go +++ b/internal/cli/action_run.go @@ -167,11 +167,19 @@ func (a *action) Run(c *cli.Context) error { return fmt.Errorf("failed to stat %s: %w", gitDirectory, err) } + if a.flags.dryRun { + return nil + } + + if len(successUpgradeModules) == 0 { + return nil + } + gitCommitMessage := "build: upgrade modules\n" for _, module := range successUpgradeModules { gitCommitMessage += fmt.Sprintf("\n%s: %s -> %s", module.Path, module.Version, module.Update.Version) } - gitCommitArgs := []string{"commit", "-m", gitCommitMessage} + gitCommitArgs := []string{"commit", "-m", `"` + gitCommitMessage + `"`} gitOutput, err := exec.CommandContext(c.Context, "git", gitCommitArgs...).CombinedOutput() if err != nil { return fmt.Errorf("failed to run git %+v: %w", strings.Join(gitCommitArgs, " "), err)