mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
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
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user