Skip to content

Commit 0ad35e3

Browse files
committed
Add existence check for go.mod and go.sum files
Signed-off-by: Austin Vazquez <[email protected]>
1 parent 4279e52 commit 0ad35e3

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

hack/validate/vendor

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ source "${SCRIPTDIR}/.validate"
88
tidy_files=('go.mod' 'go.sum')
99
vendor_files=("${tidy_files[@]}" 'vendor/')
1010

11+
validate_vendor_files_exist() {
12+
local file
13+
for file in "${vendor_files[@]}"; do
14+
if [ ! -e "$file" ]; then
15+
echo >&2 "ERROR: required file '$file' does not exist"
16+
return 1
17+
fi
18+
done
19+
return 0
20+
}
21+
1122
validate_vendor_tidy() {
1223
# run mod tidy
1324
./hack/vendor.sh tidy
@@ -37,6 +48,16 @@ validate_vendor_license() {
3748
done < <(awk '/^# /{ print $2 }' vendor/modules.txt)
3849
}
3950

51+
# First check the required files exist as git diff will not report missing files.
52+
if ! validate_vendor_files_exist; then
53+
{
54+
echo 'FAIL: Vendoring was not performed correctly!'
55+
echo
56+
echo 'Please revendor with hack/vendor.sh'
57+
} >&2
58+
exit 1
59+
fi
60+
4061
if validate_vendor_tidy && validate_vendor_diff && validate_vendor_license; then
4162
echo >&2 'PASS: Vendoring has been performed correctly!'
4263
else

0 commit comments

Comments
 (0)