mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:56:45 +08:00
optional to hide outputs.
This commit is contained in:
1 parent
61ac03e7b4
commit
70144e6ee0
8 files changed
+22
-16
No files matched your search
+11
-5
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user