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()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitWrapper(commit string, flags []string) {
|
func GitWrapper(commit string, flags []string) error {
|
||||||
// commit shell command
|
// commit shell command
|
||||||
// specify git command
|
// specify git command
|
||||||
input := []string{"commit"}
|
input := []string{"commit"}
|
||||||
@@ -73,22 +73,27 @@ func GitWrapper(commit string, flags []string) {
|
|||||||
cmd_output, err := cmd.CombinedOutput()
|
cmd_output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(fmt.Sprint(err) + " : " + string(cmd_output))
|
return fmt.Errorf("error: %s : %s", err, string(cmd_output))
|
||||||
} else {
|
} else {
|
||||||
println(string(cmd_output))
|
println(string(cmd_output))
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitPush() {
|
func GitPush(flags []string) error {
|
||||||
cmd := exec.Command("git", "push")
|
|
||||||
|
input := []string{"push"}
|
||||||
|
input = append(input, flags...)
|
||||||
|
cmd := exec.Command("git", input...)
|
||||||
|
|
||||||
cmd_output, err := cmd.CombinedOutput()
|
cmd_output, err := cmd.CombinedOutput()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println(fmt.Sprint(err) + " : " + string(cmd_output))
|
return fmt.Errorf("error: %s : %s", err, string(cmd_output))
|
||||||
} else {
|
} else {
|
||||||
println(string(cmd_output))
|
println(string(cmd_output))
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to add an author to the commit message
|
// helper function to add an author to the commit message
|
||||||
|
|||||||
Reference in New Issue
Block a user