Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #40148 from kolyshkin/vendor-diff
Browse files Browse the repository at this point in the history
hack/validate/vendor: print diff for modified files
Upstream-commit: e9bd017b680cf3eb05d8db21500979ac22969658
Component: engine
  • Loading branch information
thaJeztah authored Nov 7, 2019
2 parents 131d816 + 34a3ace commit e1c76bc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/engine/hack/validate/vendor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${SCRIPTDIR}/.validate"

validate_vendor_diff(){
Expand All @@ -13,6 +13,7 @@ validate_vendor_diff(){
vndr
# check if any files have changed
diffs="$(git status --porcelain -- vendor 2>/dev/null)"
mfiles="$(echo "$diffs" | awk '/^ M / {print $2}')"
if [ "$diffs" ]; then
{
echo 'The result of vndr differs'
Expand All @@ -21,6 +22,9 @@ validate_vendor_diff(){
echo
echo 'Please vendor your package with github.com/LK4D4/vndr.'
echo
if [ -n "$mfiles" ] ; then
git diff -- "$mfiles"
fi
} >&2
false
else
Expand All @@ -34,11 +38,10 @@ validate_vendor_diff(){
# 1. make sure all the vendored packages are used
# 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
validate_vendor_used() {
pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf)
for f in $pkgs; do
if ls -d vendor/$f > /dev/null 2>&1; then
found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
if [ $found -eq 0 ]; then
for f in $(mawk '/^[a-zA-Z0-9]/ { print $1 }' vendor.conf); do
if [ -d "vendor/$f" ]; then
found=$(echo "vendor/$f/"* | grep -iEc '/(LICENSE|COPYING)')
if [ "$found" -eq 0 ]; then
echo "WARNING: could not find copyright information for $f"
fi
else
Expand Down

0 comments on commit e1c76bc

Please sign in to comment.