mirror of
https://github.com/containers/skopeo.git
synced 2025-05-04 22:16:43 +00:00
Validating only committed files is not useful in the natural $test_everything_passes; commit; push workflow; the failures will not be caught locally, only by Travis later (and only if PRs are used instead of direct commits to master). So, use the working directory state instead of last commit for validations; and remove misleading comments in checks which already use the working directory state.
30 lines
613 B
Bash
Executable File
30 lines
613 B
Bash
Executable File
#!/bin/bash
|
|
|
|
source "$(dirname "$BASH_SOURCE")/.validate"
|
|
|
|
IFS=$'\n'
|
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
|
unset IFS
|
|
|
|
badFiles=()
|
|
for f in "${files[@]}"; do
|
|
if [ "$(gofmt -s -l < $f)" ]; then
|
|
badFiles+=( "$f" )
|
|
fi
|
|
done
|
|
|
|
if [ ${#badFiles[@]} -eq 0 ]; then
|
|
echo 'Congratulations! All Go source files are properly formatted.'
|
|
else
|
|
{
|
|
echo "These files are not properly gofmt'd:"
|
|
for f in "${badFiles[@]}"; do
|
|
echo " - $f"
|
|
done
|
|
echo
|
|
echo 'Please reformat the above files using "gofmt -s -w" and commit the result.'
|
|
echo
|
|
} >&2
|
|
false
|
|
fi
|