@ -69,6 +69,7 @@ func newFileCollector(fileFilter string, batchSize int) (*fileCollector, error)
co . includePatterns = append ( co . includePatterns , regexp . MustCompile ( ` .*\.go$ ` ) )
co . excludePatterns = append ( co . excludePatterns , regexp . MustCompile ( ` .*\bbindata\.go$ ` ) )
co . excludePatterns = append ( co . excludePatterns , regexp . MustCompile ( ` \.pb\.go$ ` ) )
co . excludePatterns = append ( co . excludePatterns , regexp . MustCompile ( ` tests/gitea-repositories-meta ` ) )
co . excludePatterns = append ( co . excludePatterns , regexp . MustCompile ( ` tests/integration/migration-test ` ) )
co . excludePatterns = append ( co . excludePatterns , regexp . MustCompile ( ` modules/git/tests ` ) )
@ -203,17 +204,6 @@ Example:
` , "file-batch-exec" )
}
func getGoVersion ( ) string {
goModFile , err := os . ReadFile ( "go.mod" )
if err != nil {
log . Fatalf ( ` Faild to read "go.mod": %v ` , err )
os . Exit ( 1 )
}
goModVersionRegex := regexp . MustCompile ( ` go \d+\.\d+ ` )
goModVersionLine := goModVersionRegex . Find ( goModFile )
return string ( goModVersionLine [ 3 : ] )
}
func newFileCollectorFromMainOptions ( mainOptions map [ string ] string ) ( fc * fileCollector , err error ) {
fileFilter := mainOptions [ "file-filter" ]
if fileFilter == "" {
@ -278,7 +268,8 @@ func main() {
log . Print ( "the -d option is not supported by gitea-fmt" )
}
cmdErrors = append ( cmdErrors , giteaFormatGoImports ( files , containsString ( subArgs , "-w" ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "GOFUMPT_PACKAGE" ) , "-extra" , "-lang" , getGoVersion ( ) } , substArgs ... ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "gofmt" , append ( [ ] string { "-w" , "-r" , "interface{} -> any" } , substArgs ... ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "GOFUMPT_PACKAGE" ) , "-extra" } , substArgs ... ) ) )
default :
log . Fatalf ( "unknown cmd: %s %v" , subCmd , subArgs )
}