optional to hide outputs.

This commit is contained in:
Daveberry committed 2026-06-10 01:08:12 +08:00
1 parent 61ac03e7b4
commit 70144e6ee0
8 files changed
+22 -16

No files matched your search

+11 -5
View File
@@ -2,23 +2,29 @@ package utils
import (
"fmt"
"io"
"os"
"os/exec"
"strings"
)
func RunGit(args ...string) error {
func RunGit(hideOutput bool, args ...string) error {
gitCmd := exec.Command("git", args...)
gitCmd.Stdin = os.Stdin
gitCmd.Stdout = os.Stdout
gitCmd.Stderr = os.Stderr
if hideOutput {
gitCmd.Stdout = io.Discard
gitCmd.Stderr = io.Discard
} else {
gitCmd.Stdout = os.Stdout
gitCmd.Stderr = os.Stderr
}
return gitCmd.Run()
}
func RunGitSequence(commands ...[]string) error {
func RunGitSequence(hideOutput bool, commands ...[]string) error {
for _, commandArgs := range commands {
if err := RunGit(commandArgs...); err != nil {
if err := RunGit(hideOutput, commandArgs...); err != nil {
return fmt.Errorf("git %s failed: %w", strings.Join(commandArgs, " "), err)
}
}