mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
b1c4df81c8
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
37 lines
571 B
Go
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)
|
|
}
|