From 4696f58bf5cb79d8bb591f3b2ba0971885284ffa Mon Sep 17 00:00:00 2001 From: Slug-Boi Date: Wed, 9 Apr 2025 21:00:51 +0200 Subject: [PATCH] refactor: add error returns and flags --- src/cmd/utils/commit.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cmd/utils/commit.go b/src/cmd/utils/commit.go index 1b316fe..8e5b029 100644 --- a/src/cmd/utils/commit.go +++ b/src/cmd/utils/commit.go @@ -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