Files
cocommit/src_code/go_src/cmd/utils/cz_utils.go
T
Slug-Boi b1c4df81c8 feat: added commitizen support (due to cmd execution styles this will not be in the test suite)
Due to the way that the interactive cli call has to be made there is no
good way to automate the tests for it without spending a long time
trying to understand go pipes. since this is more of an extra feature
anyways I am fine with leaving this somewhat untested especially since
it is small isolated code
2024-10-31 21:24:17 +01:00

37 lines
571 B
Go

package utils
import (
"fmt"
"io"
"os"
"os/exec"
)
func Cz_Call() string {
// create commitizen command
cmd := exec.Command("cz", "commit", "--dry-run", "--write-message-to-file", "msg")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
panic(fmt.Sprint(err))
}
file, err := os.OpenFile("msg", os.O_RDONLY, 0644)
defer os.Remove("msg")
defer file.Close()
if err != nil {
panic(fmt.Sprint(err))
}
msg, err := io.ReadAll(file)
if err != nil {
panic(fmt.Sprint(err))
}
return string(msg)
}