From 00c1a61c3af1f07f5770447432cd3353851b934a Mon Sep 17 00:00:00 2001 From: Manu Date: Wed, 8 Nov 2023 15:25:40 +0100 Subject: [PATCH] fix: project_modified directory --- template-sync.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/template-sync.sh b/template-sync.sh index 27fb8ef..54a6e39 100755 --- a/template-sync.sh +++ b/template-sync.sh @@ -41,6 +41,7 @@ cd "$temp_dir" || return mkdir template mkdir project mkdir template_modified +mkdir project_modified git_template_sync() { if [ "$debug" = true ]; then @@ -67,28 +68,28 @@ removing_useless_files() { estimate_similarity_index() { git_template_sync checkout "$sha" - cp -r . ../template_modified - cp -r ../project ../project_modified + cp -r . ../template_modified + cp -r ../project ../project_modified - removing_useless_files "../template_modified" - total_template_modified_files=$(find "../template_modified" -type f | wc -l) + removing_useless_files "../template_modified" + total_template_modified_files=$(find "../template_modified" -type f | wc -l) - removing_useless_files "../project_modified" - - cd .. - tmpfile1=$(mktemp) - tmpfile2=$(mktemp) + removing_useless_files "../project_modified" + + cd .. + tmpfile1=$(mktemp) + tmpfile2=$(mktemp) - (find template_modified/ -type f | sort | sed -e 's|template_modified/||' -e 's/\.yml/\.yaml/') > "$tmpfile1" + (find template_modified/ -type f | sort | sed -e 's|template_modified/||' -e 's/\.yml/\.yaml/') > "$tmpfile1" - (find project_modified/ -type f | sort | sed -e 's|project_modified/||' -e 's/\.yml/\.yaml/') > "$tmpfile2" + (find project_modified/ -type f | sort | sed -e 's|project_modified/||' -e 's/\.yml/\.yaml/') > "$tmpfile2" - common_files=$(comm -12 "$tmpfile1" "$tmpfile2" | wc -l) - - rm "$tmpfile1" "$tmpfile2" + common_files=$(comm -12 "$tmpfile1" "$tmpfile2" | wc -l) + + rm "$tmpfile1" "$tmpfile2" - ratio=$(echo "scale=4; $common_files / $total_template_modified_files" | bc) - ratio_percent=$(printf "%.0f" "$(echo "$ratio * 100" | bc)") + ratio=$(echo "scale=4; $common_files / $total_template_modified_files" | bc) + ratio_percent=$(printf "%.0f" "$(echo "$ratio * 100" | bc)") } git_template_sync clone "$url" template/ @@ -124,6 +125,7 @@ done ratioThreshold=$(echo "$ratioMax - ($ratioMax - $ratioMin) / 3" | bc) rm -rf ../template_modified/* +rm -rf ../project_modified/* index=0 for sha in $api_shas;