mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Add existence check for go.mod and go.sum files
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
(cherry picked from commit 0ad35e3ef0)
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -8,6 +8,17 @@ source "${SCRIPTDIR}/.validate"
|
||||
tidy_files=('vendor.mod' 'vendor.sum')
|
||||
vendor_files=("${tidy_files[@]}" 'vendor/')
|
||||
|
||||
validate_vendor_files_exist() {
|
||||
local file
|
||||
for file in "${vendor_files[@]}"; do
|
||||
if [ ! -e "$file" ]; then
|
||||
echo >&2 "ERROR: required file '$file' does not exist"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_vendor_tidy() {
|
||||
# run mod tidy
|
||||
./hack/vendor.sh tidy
|
||||
@@ -37,6 +48,16 @@ validate_vendor_license() {
|
||||
done < <(awk '/^# /{ print $2 }' vendor/modules.txt)
|
||||
}
|
||||
|
||||
# First check the required files exist as git diff will not report missing files.
|
||||
if ! validate_vendor_files_exist; then
|
||||
{
|
||||
echo 'FAIL: Vendoring was not performed correctly!'
|
||||
echo
|
||||
echo 'Please revendor with hack/vendor.sh'
|
||||
} >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if validate_vendor_tidy && validate_vendor_diff && validate_vendor_license; then
|
||||
echo >&2 'PASS: Vendoring has been performed correctly!'
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user