mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-04 18:52:38 +00:00
First commit
This commit is contained in:
10
hooks/commit-msg
Executable file
10
hooks/commit-msg
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$(grep -c "# then delete this line" $1)" == "1" ]]; then
|
||||
echo "Unresolved gofmt errors. Aborting commit."
|
||||
echo "The message of your attempted commit was:"
|
||||
cat $1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
17
hooks/prepare-commit-msg
Executable file
17
hooks/prepare-commit-msg
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
errors=0
|
||||
for file in $(git diff --cached --name-only | grep "\.go"); do
|
||||
diff="$(gofmt -d "${file}")"
|
||||
if [[ -n "$diff" ]]; then
|
||||
echo "# *** ERROR: *** File ${file} has not been gofmt'd." >> $1
|
||||
errors=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $errors == "1" ]]; then
|
||||
echo "# To fix these errors, run gofmt -w <file>." >> $1
|
||||
echo "# If you want to commit in spite of these format errors," >> $1
|
||||
echo "# then delete this line. Otherwise, your commit will be" >> $1
|
||||
echo "# aborted." >> $1
|
||||
fi
|
Reference in New Issue
Block a user