mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-14 19:20:37 +03:00
Replace lefthook with shell script
This commit is contained in:
parent
e7f6ba8f35
commit
037f6b606e
15
Makefile
15
Makefile
@ -48,16 +48,20 @@ setup:
|
|||||||
@(cd ./ui && npm ci)
|
@(cd ./ui && npm ci)
|
||||||
.PHONY: setup
|
.PHONY: setup
|
||||||
|
|
||||||
setup-dev: setup
|
setup-dev: setup setup-git
|
||||||
@which wire || (echo "Installing Wire" && GO111MODULE=off go get -u github.com/google/wire/cmd/wire)
|
@which wire || (echo "Installing Wire" && GO111MODULE=off go get -u github.com/google/wire/cmd/wire)
|
||||||
@which ginkgo || (echo "Installing Ginkgo" && GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo)
|
@which ginkgo || (echo "Installing Ginkgo" && GO111MODULE=off go get -u github.com/onsi/ginkgo/ginkgo)
|
||||||
@which goose || (echo "Installing Goose" && GO111MODULE=off go get -u github.com/pressly/goose/cmd/goose)
|
@which goose || (echo "Installing Goose" && GO111MODULE=off go get -u github.com/pressly/goose/cmd/goose)
|
||||||
@which reflex || (echo "Installing Reflex" && GO111MODULE=off go get -u github.com/cespare/reflex)
|
@which reflex || (echo "Installing Reflex" && GO111MODULE=off go get -u github.com/cespare/reflex)
|
||||||
@which golangci-lint || (echo "Installing GolangCI-Lint" && cd .. && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0)
|
@which golangci-lint || (echo "Installing GolangCI-Lint" && cd .. && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.27.0)
|
||||||
@which lefthook || (echo "Installing Lefthook" && GO111MODULE=off go get -u github.com/Arkweid/lefthook)
|
@which goimports || (echo "Installing goimports" && GO111MODULE=off go get -u golang.org/x/tools/cmd/goimports)
|
||||||
@lefthook install
|
|
||||||
.PHONY: setup-dev
|
.PHONY: setup-dev
|
||||||
|
|
||||||
|
setup-git:
|
||||||
|
@mkdir -p .git/hooks
|
||||||
|
(cd .git/hooks && ln -sf ../../git/* .)
|
||||||
|
.PHONY: setup-git
|
||||||
|
|
||||||
Jamstash-master:
|
Jamstash-master:
|
||||||
wget -N https://github.com/tsquillario/Jamstash/archive/master.zip
|
wget -N https://github.com/tsquillario/Jamstash/archive/master.zip
|
||||||
unzip -o master.zip
|
unzip -o master.zip
|
||||||
@ -68,11 +72,6 @@ Jamstash-master:
|
|||||||
check_env: check_go_env check_node_env
|
check_env: check_go_env check_node_env
|
||||||
.PHONY: check_env
|
.PHONY: check_env
|
||||||
|
|
||||||
check_hooks:
|
|
||||||
@lefthook add pre-commit
|
|
||||||
@lefthook add pre-push
|
|
||||||
.PHONY: check_hooks
|
|
||||||
|
|
||||||
check_go_env:
|
check_go_env:
|
||||||
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
|
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
|
||||||
@go version | grep -q $(GO_VERSION) || (echo "\nERROR: Please upgrade your GO version\nThis project requires version $(GO_VERSION)"; exit 1)
|
@go version | grep -q $(GO_VERSION) || (echo "\nERROR: Please upgrade your GO version\nThis project requires version $(GO_VERSION)"; exit 1)
|
||||||
|
32
git/pre-commit
Executable file
32
git/pre-commit
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright 2012 The Go Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style
|
||||||
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
# git gofmt pre-commit hook
|
||||||
|
#
|
||||||
|
# To use, store as .git/hooks/pre-commit inside your repository and make sure
|
||||||
|
# it has execute permissions.
|
||||||
|
#
|
||||||
|
# This script does not handle file names that contain spaces.
|
||||||
|
|
||||||
|
if which goimports > /dev/null; then
|
||||||
|
gofmtcmd=goimports
|
||||||
|
else
|
||||||
|
gofmtcmd=gofmt
|
||||||
|
fi
|
||||||
|
|
||||||
|
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')
|
||||||
|
[ -z "$gofiles" ] && exit 0
|
||||||
|
|
||||||
|
unformatted=$($gofmtcmd -l $gofiles)
|
||||||
|
[ -z "$unformatted" ] && exit 0
|
||||||
|
|
||||||
|
# Some files are not gofmt'd. Print message and fail.
|
||||||
|
|
||||||
|
echo >&2 "Go files must be formatted with '$gofmtcmd'. Please run:"
|
||||||
|
for fn in $unformatted; do
|
||||||
|
echo >&2 " $gofmtcmd -w $PWD/$fn"
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 1
|
4
git/pre-push
Executable file
4
git/pre-push
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
golangci-lint run
|
||||||
|
make test
|
17
lefthook.yml
17
lefthook.yml
@ -1,17 +0,0 @@
|
|||||||
pre-push:
|
|
||||||
parallel: true
|
|
||||||
commands:
|
|
||||||
unit-tests:
|
|
||||||
tags: tests
|
|
||||||
run: go test ./...
|
|
||||||
lint:
|
|
||||||
tags: tests
|
|
||||||
run: golangci-lint run
|
|
||||||
|
|
||||||
pre-commit:
|
|
||||||
parallel: false
|
|
||||||
commands:
|
|
||||||
gofmt:
|
|
||||||
tags: style
|
|
||||||
glob: "*.go"
|
|
||||||
run: gofmt -w {staged_files}; git add {staged_files}
|
|
Loading…
x
Reference in New Issue
Block a user