mirror of https://github.com/Wilfred/difftastic/
Simplify parse-examples script
Also, in that script, parse .tsx files, not just .ts filesida_star
parent
1e86f0c386
commit
13b35c16b8
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
function clone_repo {
|
||||
owner=$1
|
||||
name=$2
|
||||
sha=$3
|
||||
|
||||
path=examples/$name
|
||||
if [ ! -d "$path" ]; then
|
||||
echo "Cloning $owner/$name"
|
||||
git clone "https://github.com/$owner/$name" "$path"
|
||||
fi
|
||||
|
||||
pushd "$path" > /dev/null
|
||||
if [ "$(git rev-parse head)" != "$sha" ]; then
|
||||
echo "Updating $owner/$name to $sha"
|
||||
git fetch
|
||||
git reset --hard $sha
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
clone_repo desktop desktop d1324f56d02dd9afca5d2e9da545905a7d41d671
|
||||
|
||||
known_failures="$(cat script/known_failures.txt)"
|
||||
|
||||
tree-sitter parse -q \
|
||||
'examples/**/*.ts*' \
|
||||
$(for failure in $known_failures; do echo "!${failure}"; done)
|
||||
|
||||
example_count=$(find examples -name '*.ts*' | wc -l)
|
||||
failure_count=$(wc -w <<< "$known_failures")
|
||||
success_count=$(( $example_count - $failure_count ))
|
||||
success_percent=$(bc -l <<< "100*${success_count}/${example_count}")
|
||||
|
||||
printf \
|
||||
"Successfully parsed %d of %d example files (%.1f%%)\n" \
|
||||
$success_count $example_count $success_percent
|
||||
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
|
||||
# Clone desktop/desktop and check out a known sha
|
||||
repo=examples/desktop
|
||||
|
||||
if [ ! -d "$repo" ]; then
|
||||
git clone https://github.com/desktop/desktop "$repo"
|
||||
fi
|
||||
|
||||
pushd "$repo" && git fetch
|
||||
git reset --hard d1324f56d02dd9afca5d2e9da545905a7d41d671
|
||||
popd
|
||||
|
||||
tree-sitter parse examples/*.ts -qt
|
||||
|
||||
# TODO: Fix known issues in known_failures.txt
|
||||
known_failures=$(cat script/known_failures.txt)
|
||||
examples_to_parse=$(
|
||||
for example in $(find "$repo" -name '*.ts'); do
|
||||
if [[ ! $known_failures == *$example* ]]; then
|
||||
echo $example
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
echo $examples_to_parse | xargs -n 5000 tree-sitter parse -q
|
||||
|
||||
skipped=$( echo $known_failures | wc -w )
|
||||
parsed=$( echo $examples_to_parse | wc -w )
|
||||
total=$((parsed+skipped))
|
||||
percent=$(bc -l <<< "100*$parsed/$total")
|
||||
|
||||
printf "Successfully parsed %.2f%% of $repo (%d of %d files)\n" $percent $parsed $total
|
||||
Loading…
Reference in New Issue