check_for_blobs.sh: respect gitignore (#876)
This commit is contained in:
parent
b9bd0dd6b7
commit
8e6eaf7002
@ -1,19 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
blobs=$(find . -type f -exec sh -c '
|
declare -a blobs
|
||||||
for f; do
|
|
||||||
mimetype -b "$f" | grep -Eq "application/(x-object|x-executable)" &&
|
|
||||||
printf "%s\n" "$f"
|
|
||||||
done
|
|
||||||
' sh {} +)
|
|
||||||
|
|
||||||
if [ -z "$blobs" ]
|
KNOWN_GOOD_FILE_EXTENSIONS=("rs" "c" "h" "cc" "sh" "py" "toml" "yml" "json" "md" "gitignore" "png")
|
||||||
|
|
||||||
|
while read -r file; do
|
||||||
|
# NOTE: mimetype detection spawns a perl process for each file and is pretty slow.
|
||||||
|
# we work around this by skipping files with known-good extensions.
|
||||||
|
ext="${file##*.}"
|
||||||
|
for skipExt in "${KNOWN_GOOD_FILE_EXTENSIONS[@]}"; do
|
||||||
|
if [ "$ext" = "$skipExt" ]; then
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if mimetype -b "$file" | grep -Eq "application/(x-object|x-executable)"; then
|
||||||
|
blobs+=("$file");
|
||||||
|
fi
|
||||||
|
done < <(git ls-files --exclude-standard --cached --others)
|
||||||
|
|
||||||
|
if [ ${#blobs[@]} -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "No object or executable files in the root directory"
|
echo "No object or executable files in the root directory"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Hey! There are some object or executable file in the root directory!"
|
echo "Hey! There are some object or executable file in the root directory!"
|
||||||
echo "$blobs"
|
echo "${blobs[@]}"
|
||||||
echo "Aborting."
|
echo "Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user