Skip to content

Commit cd89592

Browse files
author
Rodrigo Navarro
committed
no-story (feature): Add command exec output to os.sdtout
1 parent 172654e commit cd89592

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/git/git.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package git
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"os"
@@ -26,14 +27,13 @@ func CheckTree() {
2627
}
2728

2829
func commit(cmdGit *exec.Cmd, message ...interface{}) {
29-
output, err := cmdGit.Output()
30-
checkErr(err)
31-
3230
fmt.Println("")
3331
fmt.Println("Committing: ", color.Blue(message))
3432
fmt.Println(color.Gray("-------------------------------"))
3533
fmt.Println("")
36-
fmt.Println(color.Gray(string(output)))
34+
cmdGit.Stdout = os.Stdout
35+
cmdGit.Run()
36+
fmt.Println("")
3737
fmt.Println(color.Gray("-------------------------------"))
3838
fmt.Println(color.Green("Done \U0001F604"))
3939

@@ -42,15 +42,17 @@ func commit(cmdGit *exec.Cmd, message ...interface{}) {
4242

4343
// Commit execute commit
4444
func Commit(message string) (err error) {
45-
cmdGit := exec.Command("git", "commit", "-m", message)
45+
ctx := context.Background()
46+
cmdGit := exec.CommandContext(ctx, "git", "commit", "-m", message)
4647
commit(cmdGit, "Committing: ", color.Blue(message))
4748

4849
return
4950
}
5051

5152
// Amend execute commit amend
5253
func Amend(message string) (err error) {
53-
cmdGit := exec.Command("git", "commit", "--amend", "-m", message)
54+
ctx := context.Background()
55+
cmdGit := exec.CommandContext(ctx, "git", "commit", "--amend", "-m", message)
5456
commit(cmdGit, "Amending: ", color.Blue(message))
5557

5658
return

0 commit comments

Comments
 (0)