mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
refactor: add error returns and flags
This commit is contained in:
+10
-5
@@ -58,7 +58,7 @@ if len(excludeMode) > 0 {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func GitWrapper(commit string, flags []string) {
|
||||
func GitWrapper(commit string, flags []string) error {
|
||||
// commit shell command
|
||||
// specify git command
|
||||
input := []string{"commit"}
|
||||
@@ -73,22 +73,27 @@ func GitWrapper(commit string, flags []string) {
|
||||
cmd_output, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
println(fmt.Sprint(err) + " : " + string(cmd_output))
|
||||
return fmt.Errorf("error: %s : %s", err, string(cmd_output))
|
||||
} else {
|
||||
println(string(cmd_output))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GitPush() {
|
||||
cmd := exec.Command("git", "push")
|
||||
func GitPush(flags []string) error {
|
||||
|
||||
input := []string{"push"}
|
||||
input = append(input, flags...)
|
||||
cmd := exec.Command("git", input...)
|
||||
|
||||
cmd_output, err := cmd.CombinedOutput()
|
||||
|
||||
if err != nil {
|
||||
println(fmt.Sprint(err) + " : " + string(cmd_output))
|
||||
return fmt.Errorf("error: %s : %s", err, string(cmd_output))
|
||||
} else {
|
||||
println(string(cmd_output))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// helper function to add an author to the commit message
|
||||
|
||||
Reference in New Issue
Block a user