mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 03:02:14 +01:00 
			
		
		
		
	Misc tool tweaks (#35734)
Some minor tooling tweaks: - Ignore .venv in golangci-lint - Move go tools to tools directory (e.g. everything that is not "build") - Enable reportUnusedInlineConfigs in eslint, no current violations - Apply modernize fix in code-batch-process, modernize cli did apparently not catch it because of the `go:build ignore` tag.
This commit is contained in:
		
							parent
							
								
									cab35ff17a
								
							
						
					
					
						commit
						e03a68c48b
					
				| @ -153,6 +153,7 @@ linters: | |||||||
|         text: '(?i)exitAfterDefer:' |         text: '(?i)exitAfterDefer:' | ||||||
|     paths: |     paths: | ||||||
|       - node_modules |       - node_modules | ||||||
|  |       - .venv | ||||||
|       - public |       - public | ||||||
|       - web_src |       - web_src | ||||||
|       - third_party$ |       - third_party$ | ||||||
| @ -172,6 +173,7 @@ formatters: | |||||||
|     generated: lax |     generated: lax | ||||||
|     paths: |     paths: | ||||||
|       - node_modules |       - node_modules | ||||||
|  |       - .venv | ||||||
|       - public |       - public | ||||||
|       - web_src |       - web_src | ||||||
|       - third_party$ |       - third_party$ | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -258,7 +258,7 @@ clean: ## delete backend and integration files | |||||||
| 
 | 
 | ||||||
| .PHONY: fmt | .PHONY: fmt | ||||||
| fmt: ## format the Go and template code
 | fmt: ## format the Go and template code
 | ||||||
| 	@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}' | 	@GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run tools/code-batch-process.go gitea-fmt -w '{file-list}' | ||||||
| 	$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) | 	$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl')) | ||||||
| 	@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only | 	@# strip whitespace after '{{' or '(' and before '}}' or ')' unless there is only | ||||||
| 	@# whitespace before it | 	@# whitespace before it | ||||||
| @ -472,7 +472,7 @@ test\#%: | |||||||
| coverage: | coverage: | ||||||
| 	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out | 	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' coverage.out > coverage-bodged.out | ||||||
| 	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out | 	grep '^\(mode: .*\)\|\(.*:[0-9]\+\.[0-9]\+,[0-9]\+\.[0-9]\+ [0-9]\+ [0-9]\+\)$$' integration.coverage.out > integration.coverage-bodged.out | ||||||
| 	$(GO) run build/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all | 	$(GO) run tools/gocovmerge.go integration.coverage-bodged.out coverage-bodged.out > coverage.all | ||||||
| 
 | 
 | ||||||
| .PHONY: unit-test-coverage | .PHONY: unit-test-coverage | ||||||
| unit-test-coverage: | unit-test-coverage: | ||||||
|  | |||||||
| @ -49,6 +49,7 @@ export default defineConfig([ | |||||||
|     }, |     }, | ||||||
|     linterOptions: { |     linterOptions: { | ||||||
|       reportUnusedDisableDirectives: 2, |       reportUnusedDisableDirectives: 2, | ||||||
|  |       reportUnusedInlineConfigs: 2, | ||||||
|     }, |     }, | ||||||
|     plugins: { |     plugins: { | ||||||
|       '@eslint-community/eslint-comments': comments, |       '@eslint-community/eslint-comments': comments, | ||||||
|  | |||||||
| @ -114,7 +114,7 @@ ENABLED = true | |||||||
| [markup.html] | [markup.html] | ||||||
| ENABLED = true | ENABLED = true | ||||||
| FILE_EXTENSIONS = .html | FILE_EXTENSIONS = .html | ||||||
| RENDER_COMMAND = go run build/test-echo.go | RENDER_COMMAND = go run tools/test-echo.go | ||||||
| ;RENDER_COMMAND = cat | ;RENDER_COMMAND = cat | ||||||
| ;IS_INPUT_FILE = true | ;IS_INPUT_FILE = true | ||||||
| RENDER_CONTENT_MODE = sanitized | RENDER_CONTENT_MODE = sanitized | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ import ( | |||||||
| 	"os/exec" | 	"os/exec" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"regexp" | 	"regexp" | ||||||
|  | 	"slices" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| @ -217,15 +218,6 @@ func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCol | |||||||
| 	return newFileCollector(fileFilter, batchSize) | 	return newFileCollector(fileFilter, batchSize) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func containsString(a []string, s string) bool { |  | ||||||
| 	for _, v := range a { |  | ||||||
| 		if v == s { |  | ||||||
| 			return true |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return false |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func giteaFormatGoImports(files []string, doWriteFile bool) error { | func giteaFormatGoImports(files []string, doWriteFile bool) error { | ||||||
| 	for _, file := range files { | 	for _, file := range files { | ||||||
| 		if err := codeformat.FormatGoImports(file, doWriteFile); err != nil { | 		if err := codeformat.FormatGoImports(file, doWriteFile); err != nil { | ||||||
| @ -264,10 +256,10 @@ func main() { | |||||||
| 		logVerbose("batch cmd: %s %v", subCmd, substArgs) | 		logVerbose("batch cmd: %s %v", subCmd, substArgs) | ||||||
| 		switch subCmd { | 		switch subCmd { | ||||||
| 		case "gitea-fmt": | 		case "gitea-fmt": | ||||||
| 			if containsString(subArgs, "-d") { | 			if slices.Contains(subArgs, "-d") { | ||||||
| 				log.Print("the -d option is not supported by gitea-fmt") | 				log.Print("the -d option is not supported by gitea-fmt") | ||||||
| 			} | 			} | ||||||
| 			cmdErrors = append(cmdErrors, giteaFormatGoImports(files, containsString(subArgs, "-w"))) | 			cmdErrors = append(cmdErrors, giteaFormatGoImports(files, slices.Contains(subArgs, "-w"))) | ||||||
| 			cmdErrors = append(cmdErrors, passThroughCmd("gofmt", append([]string{"-w", "-r", "interface{} -> any"}, 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...))) | 			cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra"}, substArgs...))) | ||||||
| 		default: | 		default: | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user