mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Merge pull request #8411 from Calinou/update-unused-images-script
Update `list-unused-images.sh` script for recent changes
This commit is contained in:
19
_tools/list-unused-images.sh
Normal file → Executable file
19
_tools/list-unused-images.sh
Normal file → Executable file
@@ -1,4 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -uo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
check_git_history=false
|
check_git_history=false
|
||||||
|
|
||||||
@@ -9,19 +12,17 @@ rm -f tmp-unused-images-history
|
|||||||
# Exceptions are ignored, and for .svg files we also look for potential .png
|
# Exceptions are ignored, and for .svg files we also look for potential .png
|
||||||
# files with the same base name, as they might be sources.
|
# files with the same base name, as they might be sources.
|
||||||
|
|
||||||
exceptions="docs_logo.svg tween_cheatsheet.png"
|
files=$(find -name "_build" -prune -o \( -iname "*.png" -o -iname "*.webp" -o -iname "*.jpg" -o -iname "*.svg" -o -iname "*.gif" \) -print | sort)
|
||||||
|
|
||||||
files=$(find -name "_build" -prune -o \( -name "*.png" -o -name "*.jpg" -o -name "*.svg" -o -name "*.gif" \) -print | sort)
|
|
||||||
|
|
||||||
for path in $files; do
|
for path in $files; do
|
||||||
file=$(basename $path)
|
file=$(basename "$path")
|
||||||
if echo "$exceptions" | grep -q "$file"; then
|
if [[ "$path" == *./img/* ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
ext=${file##*.}
|
ext=${file##*.}
|
||||||
base=${file%.*}
|
base=${file%.*}
|
||||||
found=$(rg -l ":: .*[ /]$file")
|
found=$(rg -l ":: .*[ /]$file")
|
||||||
if [ -z "$found" -a "$ext" == "svg" ]; then
|
if [ -z "$found" ] && [ "$ext" == "svg" ]; then
|
||||||
# May be source file.
|
# May be source file.
|
||||||
found=$(rg -l ":: .*[ /]$base.png")
|
found=$(rg -l ":: .*[ /]$base.png")
|
||||||
fi
|
fi
|
||||||
@@ -30,11 +31,13 @@ for path in $files; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Wrote list of unused images to: tmp-unused-images"
|
||||||
|
|
||||||
if [ "$check_git_history" = true ]; then
|
if [ "$check_git_history" = true ]; then
|
||||||
for file in $(cat tmp-unused-images); do
|
for file in $(cat tmp-unused-images); do
|
||||||
echo "File: $file"
|
echo "File: $file"
|
||||||
git log --diff-filter=A --follow $file
|
git log --diff-filter=A --follow "$file"
|
||||||
echo
|
echo
|
||||||
done > tmp-unused-images-history
|
done > tmp-unused-images-history
|
||||||
|
echo "Wrote list of unused images in Git history to: tmp-unused-images-history"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user