Makefile: error out if go files aren't correctly formatted
Noticed in #1058 that our gofmt make target isn't actually erroring if someone commits misformatted code.
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -51,7 +51,7 @@ vet: | |||||||
| 	@go vet $(shell go list ./... | grep -v '/vendor/') | 	@go vet $(shell go list ./... | grep -v '/vendor/') | ||||||
|  |  | ||||||
| fmt: | fmt: | ||||||
| 	@go fmt $(shell go list ./... | grep -v '/vendor/') | 	@./scripts/gofmt $(shell go list ./... | grep -v '/vendor/') | ||||||
|  |  | ||||||
| lint: | lint: | ||||||
| 	@for package in $(shell go list ./... | grep -v '/vendor/' | grep -v '/api' | grep -v '/server/internal'); do \ | 	@for package in $(shell go list ./... | grep -v '/vendor/' | grep -v '/api' | grep -v '/server/internal'); do \ | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								scripts/gofmt
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								scripts/gofmt
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | #!/bin/bash -e | ||||||
|  |  | ||||||
|  | result=$( go fmt $@ ) | ||||||
|  | if [[ $result != "" ]]; then | ||||||
|  |     >&2 echo "The following files are not formatted correctly: $result" | ||||||
|  |     exit 1 | ||||||
|  | fi | ||||||
		Reference in New Issue
	
	Block a user