aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2022-10-16 10:11:17 +0200
committerGitHub <noreply@github.com>2022-10-16 16:11:17 +0800
commit0647df3e831c320436d42a5572a6ec6a9d23d8b1 (patch)
treefde6e41c5e353dc0fe535fa30875f00b4462a42c /build
parent9fb251fb6fa2bb857bb8f5ae27f06c9d597bc1eb (diff)
downloadgitea-0647df3e831c320436d42a5572a6ec6a9d23d8b1.tar.gz
gitea-0647df3e831c320436d42a5572a6ec6a9d23d8b1.zip
Simplify fmt-check (#21458)
`fmt-check` now simply does `fmt` before and relies on `git diff` like other checks like 'tidy-check' already do, so we can remove the argument in the tool that handles printing changed files. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'build')
-rw-r--r--build/code-batch-process.go11
-rw-r--r--build/codeformat/formatimports.go7
2 files changed, 5 insertions, 13 deletions
diff --git a/build/code-batch-process.go b/build/code-batch-process.go
index dce5288cf3..b6c4171ede 100644
--- a/build/code-batch-process.go
+++ b/build/code-batch-process.go
@@ -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)
}
diff --git a/build/codeformat/formatimports.go b/build/codeformat/formatimports.go
index 5d051b2726..1076e3a0d1 100644
--- a/build/codeformat/formatimports.go
+++ b/build/codeformat/formatimports.go
@@ -7,7 +7,6 @@ package codeformat
import (
"bytes"
"errors"
- "fmt"
"io"
"os"
"sort"
@@ -159,7 +158,7 @@ func formatGoImports(contentBytes []byte) ([]byte, error) {
}
// FormatGoImports format the imports by our rules (see unit tests)
-func FormatGoImports(file string, doChangedFiles, doWriteFile bool) error {
+func FormatGoImports(file string, doWriteFile bool) error {
f, err := os.Open(file)
if err != nil {
return err
@@ -183,10 +182,6 @@ func FormatGoImports(file string, doChangedFiles, doWriteFile bool) error {
return nil
}
- if doChangedFiles {
- fmt.Println(file)
- }
-
if doWriteFile {
f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {