@@ -9,53 +9,8 @@ import (
99 "path/filepath"
1010 "runtime/debug"
1111 "strings"
12-
13- "github.com/conventionalcommit/commitlint/config"
14- "github.com/conventionalcommit/commitlint/lint"
1512)
1613
17- func runLint (confFilePath , fileInput string ) (lintResult string , hasError bool , err error ) {
18- linter , format , err := getLinter (confFilePath )
19- if err != nil {
20- return "" , false , err
21- }
22-
23- commitMsg , err := getCommitMsg (fileInput )
24- if err != nil {
25- return "" , false , err
26- }
27-
28- res , err := linter .Lint (commitMsg )
29- if err != nil {
30- return "" , false , err
31- }
32-
33- resStr , err := format .Format (res )
34- if err != nil {
35- return "" , false , err
36- }
37- return resStr , res .HasErrors (), nil
38- }
39-
40- func getLinter (confFilePath string ) (* lint.Linter , lint.Formatter , error ) {
41- conf , err := config .GetConfig (confFilePath )
42- if err != nil {
43- return nil , nil , err
44- }
45-
46- format , err := config .GetFormatter (conf )
47- if err != nil {
48- return nil , nil , err
49- }
50-
51- linter , err := config .GetLinter (conf )
52- if err != nil {
53- return nil , nil , err
54- }
55-
56- return linter , format , nil
57- }
58-
5914func setGitConf (hookDir string , isGlobal bool ) error {
6015 var args = []string {"config" }
6116 if isGlobal {
@@ -68,28 +23,6 @@ func setGitConf(hookDir string, isGlobal bool) error {
6823 return cmd .Run ()
6924}
7025
71- func getCommitMsg (fileInput string ) (string , error ) {
72- commitMsg , err := readStdInPipe ()
73- if err != nil {
74- return "" , err
75- }
76-
77- if commitMsg != "" {
78- return commitMsg , nil
79- }
80-
81- // TODO: check if currentDir is inside git repo?
82- if fileInput == "" {
83- fileInput = "./.git/COMMIT_EDITMSG"
84- }
85-
86- inBytes , err := os .ReadFile (fileInput )
87- if err != nil {
88- return "" , err
89- }
90- return string (inBytes ), nil
91- }
92-
9326func readStdInPipe () (string , error ) {
9427 stat , err := os .Stdin .Stat ()
9528 if err != nil {
0 commit comments