1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/.hooks/pre-commit
Christopher Fenner 174d24460c
chore(go): add pre-commit hook (#1006)
* chore(go): add pre-commit hook
run go mod tidy
add description

* use bash

* adjust indentation

* fix code climate issue

* docs: clarify git hook usage description

* Update .hooks/README.md
2019-11-27 21:16:01 +01:00

12 lines
198 B
Bash
Executable File

#!/bin/bash
STAGED_GO_FILES=$(git diff --staged --name-only | grep "\.go$")
if [[ "$STAGED_GO_FILES" = "" ]]; then
exit 0
fi
echo "cleaning GO dependencies"
go mod tidy
git add go.mod go.sum