Skip to content

Commit

Permalink
remove scripts dir, fix hook (NetApp#423)
Browse files Browse the repository at this point in the history
* remove scripts dir, fix hook

* fix hook

* one more fix for bsd systems

* don't autofix, fail

* add a .git/hooks target
  • Loading branch information
based64god authored Oct 23, 2020
1 parent b4a3b4d commit ebc97a7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 128 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ k8s_codegen:
k8s_codegen_operator:
cd operator && $(MAKE) k8s_codegen

.git/hooks:
mkdir -p $@

.PHONY: install-lint lint-precommit lint-prepush
install-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin ${GOLANGCI-LINT_VERSION}

lint-precommit: install-lint
lint-precommit: .git/hooks install-lint
cp hooks/golangci-lint.sh .git/hooks/pre-commit

lint-prepush: install-lint .git/hooks/pre-push
lint-prepush: .git/hooks install-lint .git/hooks/pre-push
cp hooks/golangci-lint.sh .git/hooks/pre-push
9 changes: 5 additions & 4 deletions hooks/golangci-lint.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/bin/sh

# find staged files that end in .go
STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")
STAGED_GO_DIRS=$(git diff --cached --name-only | grep ".go$" | xargs dirname)
GO_PACKAGE_DIRS=($(echo "${STAGED_GO_DIRS}" | tr ' ' '\n' | sort -u | tr '\n' ' '))

# if nothing, don't lint. hook successful.
if [ "$STAGED_GO_FILES" = "" ]; then
if [ "$STAGED_GO_DIRS" = "" ]; then
exit 0
fi

PASS=true
for FILE in $STAGED_GO_FILES
for DIR in $GO_PACKAGE_DIRS
do
# This is where we will be testing each of our files.
golangci-lint run -E goimports --fix $FILE
golangci-lint run -E goimports $DIR
if [ $? != 0 ]; then
PASS=false
fi
Expand Down
29 changes: 0 additions & 29 deletions scripts/delete.sh

This file was deleted.

34 changes: 0 additions & 34 deletions scripts/get.sh

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/json-get.sh

This file was deleted.

29 changes: 0 additions & 29 deletions scripts/post.sh

This file was deleted.

0 comments on commit ebc97a7

Please sign in to comment.