@ -20,7 +20,7 @@ import (
)
// Windows has a limitation for command line arguments, the size can not exceed 32KB.
// So we have to feed the files to some tools (like gofmt/misspell ) batch by batch
// So we have to feed the files to some tools (like gofmt) batch by batch
// We also introduce a `gitea-fmt` command, it does better import formatting than gofmt/goimports. `gitea-fmt` calls `gofmt` internally.
@ -195,7 +195,6 @@ Options:
Commands :
% [ 1 ] s gofmt ...
% [ 1 ] s misspell ...
Arguments :
{ file - list } the file list
@ -239,9 +238,9 @@ func containsString(a []string, s string) bool {
return false
}
func giteaFormatGoImports ( files [ ] string , hasChangedFiles , doWriteFile bool ) error {
func giteaFormatGoImports ( files [ ] string , doWriteFile bool ) error {
for _ , file := range files {
if err := codeformat . FormatGoImports ( file , hasChangedFiles , doWriteFile ) ; err != nil {
if err := codeformat . FormatGoImports ( file , doWriteFile ) ; err != nil {
log . Printf ( "failed to format go imports: %s, err=%v" , file , err )
return err
}
@ -280,10 +279,8 @@ func main() {
if containsString ( subArgs , "-d" ) {
log . Print ( "the -d option is not supported by gitea-fmt" )
}
cmdErrors = append ( cmdErrors , giteaFormatGoImports ( files , containsString ( subArgs , "-l" ) , containsString ( subArgs , "- w" ) ) )
cmdErrors = append ( cmdErrors , giteaFormatGoImports ( files , containsString ( subArgs , "-w" ) ) )
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "GOFUMPT_PACKAGE" ) , "-extra" , "-lang" , getGoVersion ( ) } , substArgs ... ) ) )
case "misspell" :
cmdErrors = append ( cmdErrors , passThroughCmd ( "go" , append ( [ ] string { "run" , os . Getenv ( "MISSPELL_PACKAGE" ) } , substArgs ... ) ) )
default :
log . Fatalf ( "unknown cmd: %s %v" , subCmd , subArgs )
}