mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Meta: Only check changed files in lint-gml-format.sh
This speeds up the script from about 140ms down to <10ms, even for changesets that touch a handful of different GML files. 130ms may not feel like much, but it adds up quickly, especially since we run a dozen scripts during pre-commit.
This commit is contained in:
parent
de581ca5fd
commit
532786848b
Notes:
sideshowbarker
2024-07-17 20:58:35 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/532786848b Pull-request: https://github.com/SerenityOS/serenity/pull/15281 Reviewed-by: https://github.com/bgianfo ✅
1 changed files with 15 additions and 1 deletions
|
@ -18,4 +18,18 @@ if [ -z "${GML_FORMAT:-}" ] ; then
|
|||
GML_FORMAT="Build/lagom/gml-format"
|
||||
fi
|
||||
|
||||
find AK Base Documentation Kernel Meta Ports Tests Userland -type f -name '*.gml' -print0 | xargs -0 "${GML_FORMAT}" -i
|
||||
if [ "$#" -gt "0" ] ; then
|
||||
# We're in the middle of a pre-commit run, so we should only check the files that have
|
||||
# actually changed. The reason is that "git ls-files | grep" on the entire repo takes
|
||||
# about 100ms. That is perfectly fine during a CI run, but becomes noticable during a
|
||||
# pre-commit hook. It is unnecessary to check the entire repository on every single
|
||||
# commit, so we save some time here.
|
||||
for file in "$@"; do
|
||||
if [[ "${file}" =~ \.gml ]]; then
|
||||
echo "$file"
|
||||
fi
|
||||
done
|
||||
else
|
||||
find AK Base Documentation Kernel Meta Ports Tests Userland -type f -name '*.gml' -print
|
||||
fi \
|
||||
| xargs -r "${GML_FORMAT}" -i
|
||||
|
|
Loading…
Reference in a new issue