From d010e73e00f05b2bae2d4c5b214e547de699637f Mon Sep 17 00:00:00 2001 From: Slug-Boi Date: Fri, 30 May 2025 09:46:14 +0200 Subject: [PATCH] test: add return value of string for testing --- src/cmd/utils/commit.go | 10 +++++----- src/cmd/utils/test_git_wrapper | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 src/cmd/utils/test_git_wrapper diff --git a/src/cmd/utils/commit.go b/src/cmd/utils/commit.go index ccc7908..be7cbac 100644 --- a/src/cmd/utils/commit.go +++ b/src/cmd/utils/commit.go @@ -129,7 +129,7 @@ func group_selection(group []User, excludeMode []string) []string { return excludeMode } -func GitCommitAppender(authors string, hash string, flags []string, t,p bool) error { +func GitCommitAppender(authors string, hash string, flags []string, t,p bool) (error, string) { // Get old commit message var cmd *exec.Cmd @@ -144,7 +144,7 @@ func GitCommitAppender(authors string, hash string, flags []string, t,p bool) er out, err := cmd.Output() if err != nil { - return fmt.Errorf("error: %s", err) + return fmt.Errorf("error: %s", err), "" } // Convert the output to a string @@ -160,7 +160,7 @@ func GitCommitAppender(authors string, hash string, flags []string, t,p bool) er if p { println(old_commit + "\n" + authors) if t { - return nil + return nil, old_commit + "\n" + authors } } // append the message to the flags @@ -172,9 +172,9 @@ func GitCommitAppender(authors string, hash string, flags []string, t,p bool) er cmd_output, err := cmd.CombinedOutput() if err != nil { - return fmt.Errorf("error: %s : %s", err, string(cmd_output)) + return fmt.Errorf("error: %s : %s", err, string(cmd_output)), "" } else { println(string(cmd_output)) } - return nil + return nil, old_commit + "\n" + authors } diff --git a/src/cmd/utils/test_git_wrapper b/src/cmd/utils/test_git_wrapper new file mode 100644 index 0000000..3f3f005 --- /dev/null +++ b/src/cmd/utils/test_git_wrapper @@ -0,0 +1 @@ +Test content \ No newline at end of file