(fileInput string)
| 96 | } |
| 97 | |
| 98 | func getCommitMsg(fileInput string) (string, error) { |
| 99 | commitMsg, err := readStdInPipe() |
| 100 | if err != nil { |
| 101 | return "", err |
| 102 | } |
| 103 | |
| 104 | if commitMsg != "" { |
| 105 | return commitMsg, nil |
| 106 | } |
| 107 | |
| 108 | // TODO: check if currentDir is inside git repo? |
| 109 | if fileInput == "" { |
| 110 | fileInput = "./.git/COMMIT_EDITMSG" |
| 111 | } |
| 112 | |
| 113 | fileInput = filepath.Clean(fileInput) |
| 114 | inBytes, err := os.ReadFile(fileInput) |
| 115 | if err != nil { |
| 116 | return "", err |
| 117 | } |
| 118 | return string(inBytes), nil |
| 119 | } |
| 120 | |
| 121 | func trimRightSpace(s string) string { |
| 122 | return strings.TrimRightFunc(s, unicode.IsSpace) |
no test coverage detected