chore: ignore auto commit when dry run

main
sudo pacman -Syu 2022-07-22 22:10:38 +07:00
parent 83233ef5ea
commit fa101cad93
No known key found for this signature in database
GPG Key ID: D6CB5C6C567C47B0
1 changed files with 9 additions and 1 deletions

View File

@ -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)