gosick #1
@@ -126,11 +126,11 @@ func (a *App) List() error {
|
||||
}
|
||||
|
||||
func (a *App) Status(castle string) error {
|
||||
return runGit(filepath.Join(a.ReposDir, castle), "status")
|
||||
return runGitWithIO(filepath.Join(a.ReposDir, castle), a.Stdout, a.Stderr, "status")
|
||||
}
|
||||
|
||||
func (a *App) Diff(castle string) error {
|
||||
return runGit(filepath.Join(a.ReposDir, castle), "diff")
|
||||
return runGitWithIO(filepath.Join(a.ReposDir, castle), a.Stdout, a.Stderr, "diff")
|
||||
}
|
||||
|
||||
func (a *App) Link(castle string) error {
|
||||
@@ -511,10 +511,14 @@ func matchesIgnoredDir(castleHome string, candidate string, subdirs []string) (b
|
||||
}
|
||||
|
||||
func runGit(dir string, args ...string) error {
|
||||
return runGitWithIO(dir, os.Stdout, os.Stderr, args...)
|
||||
}
|
||||
|
||||
func runGitWithIO(dir string, stdout io.Writer, stderr io.Writer, args ...string) error {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = stdout
|
||||
cmd.Stderr = stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("git %s failed: %w", strings.Join(args, " "), err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user