Skip to content

Commit

Permalink
#85 show more
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 2, 2023
1 parent 9a80ead commit fc87848
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
48 changes: 27 additions & 21 deletions steps/aggregate-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,32 @@ if [ -e "${ddir}" ]; then
exit
fi

find "${dir}" -name '*.m' | while IFS= read -r m; do
find "$(dirname "${m}")" -name "$(basename "${m}").*" -type f -print | while IFS= read -r v; do
java=$(echo "${v}" | sed "s|${dir}||" | sed "s|\.m\..*$||")
metric=${v//${dir}${java}\.m\./}
csv=${ddir}/${metric}.csv
find "${dir}" -name '*.m' | {
declare -i sum=0
while IFS= read -r m; do
find "$(dirname "${m}")" -name "$(basename "${m}").*" -type f -print | while IFS= read -r v; do
java=$(echo "${v}" | sed "s|${dir}||" | sed "s|\.m\..*$||")
metric=${v//${dir}${java}\.m\./}
csv=${ddir}/${metric}.csv
mkdir -p "$(dirname "${csv}")"
echo "${java},$(cat "${v}")" >> "${csv}"
done
csv=${ddir}/all.csv
mkdir -p "$(dirname "${csv}")"
echo "${java},$(cat "${v}")" >> "${csv}"
java=$(echo "${m}" | sed "s|${dir}||" | sed "s|\.m$||")
printf '%s' "${java}" >> "${csv}"
for a in ${all}; do
if [ -e "${m}.${a}" ]; then
value=$(cat "${m}.${a}")
printf ",%s" "${value}" >> "${csv}"
if [ ! "${value}" = "NaN" ]; then
sum=$((sum + value))
fi
else
printf ',-' >> "${csv}"
fi
done
printf "\n" >> "${csv}"
done
csv=${ddir}/all.csv
mkdir -p "$(dirname "${csv}")"
java=$(echo "${m}" | sed "s|${dir}||" | sed "s|\.m$||")
printf '%s' "${java}" >> "${csv}"
echo "${all}" | while IFS= read -r a; do
if [ -e "${m}.${a}" ]; then
printf ",%s" "$(cat "${m}.${a}")" >> "${csv}"
else
printf ',-' >> "${csv}"
fi
done
printf "\n" >> "${csv}"
done

echo "${repo} aggregated (${pos}/${total})$("${LOCAL}/help/tdiff.sh" "${start}")"
echo "${repo} (${pos}/${total}) aggregated (sum=${sum})$("${LOCAL}/help/tdiff.sh" "${start}")"
}
2 changes: 2 additions & 0 deletions steps/clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ declare -i repo=0
sh="$(dirname "$0")/clone-repo.sh"
while IFS=',' read -r r tag tail; do
repo=$((repo+1))
if [ -z "${tag}" ]; then tag='master'; fi
if [ "${tag}" = '.' ]; then tag='master'; fi
if [ -e "${TARGET}/github/${r}" ]; then
echo "${r}: Git repo is already here (${tail})"
else
Expand Down
5 changes: 3 additions & 2 deletions tests/steps/test-aggregate-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ mkdir -p "${dir}"
touch "${dir}/Foo.java.m"
echo "42" > "${dir}/Foo.java.m.loc"
echo "256" > "${dir}/Foo.java.m.nhd"
"${LOCAL}/steps/aggregate-repo.sh" "${repo}" 1 1 'loc nhd' >/dev/null
msg=$("${LOCAL}/steps/aggregate-repo.sh" "${repo}" 1 1 'loc nhd')
echo "${msg}" | (grep "sum=0" && exit 1 || true)
test -e "${TARGET}/data/${repo}/all.csv"
test -e "${TARGET}/data/${repo}/loc.csv"
test -e "${TARGET}/data/${repo}/nhd.csv"
cat "${TARGET}/data/${repo}/loc.csv" | grep ",42" >/dev/null
echo "👍🏻 A repo cloned correctly"
echo "👍🏻 A repo aggregated correctly"

0 comments on commit fc87848

Please sign in to comment.