github.com/ecodeclub/eorm@v0.0.2-0.20231001112437-dae71da914d0/script/setup.sh (about) 1 # Copyright 2021 ecodeclub 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 SOURCE_COMMIT=.github/pre-commit 16 TARGET_COMMIT=.git/hooks/pre-commit 17 SOURCE_PUSH=.github/pre-push 18 TARGET_PUSH=.git/hooks/pre-push 19 20 # copy pre-commit file if not exist. 21 if [ ! -f $TARGET_COMMIT ]; then 22 echo "设置 git pre-commit hooks..." 23 cp $SOURCE_COMMIT $TARGET_COMMIT 24 fi 25 26 # copy pre-push file if not exist. 27 if [ ! -f $TARGET_PUSH ]; then 28 echo "设置 git pre-push hooks..." 29 cp $SOURCE_PUSH $TARGET_PUSH 30 fi 31 32 # add permission to TARGET_PUSH and TARGET_COMMIT file. 33 test -x $TARGET_PUSH || chmod +x $TARGET_PUSH 34 test -x $TARGET_COMMIT || chmod +x $TARGET_COMMIT 35 36 echo "安装 golangci-lint..." 37 go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 38 39 echo "安装 goimports..." 40 go install golang.org/x/tools/cmd/goimports@latest