Skip to content

Commit

Permalink
fix: project_modified directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mano-lis committed Nov 8, 2023
1 parent 785d448 commit 00c1a61
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions template-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 00c1a61

Please sign in to comment.