Skip to content

Commit

Permalink
#85 polish
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 2, 2023
1 parent 4271e1a commit 0bbf87b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions steps/aggregate-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ find "${dir}" -name '*.m' | while read -r m; do
csv=${ddir}/all.csv
mkdir -p "$(dirname "${csv}")"
java=$(echo "${m}" | sed "s|${dir}||" | sed "s|\.m$||")
printf "${java}" >> "${csv}"
printf '%s' "${java}" >> "${csv}"
for a in ${all}; do
if [ -e "${m}.${a}" ]; then
printf ",$(cat "${m}.${a}")" >> "${csv}"
printf ",%s" "$(cat "${m}.${a}")" >> "${csv}"
else
printf ',-' >> "${csv}"
fi
Expand Down
8 changes: 4 additions & 4 deletions steps/discover-repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
end
puts "Found #{json[:items].count} repositories in page #{page}"
break if found.count >= opts[:total]
puts "Let\'s sleep for a few seconds to cool off GitHub API (already found #{found.count} repos)..."
puts "Let's sleep for a few seconds to cool off GitHub API (already found #{found.count} repos)..."
sleep 10
page += 1
end
Expand All @@ -112,7 +112,7 @@

path = File.expand_path(opts[:csv])
FileUtils.mkdir_p(File.dirname(path))
File.write(path,
([found.first[1].keys.join(',')] + found.values.map { |m| m.values.join(',') }).join("\n")
)
lines = [found.first[1].keys.join(',')] + found.values.map { |m| m.values.join(',') }
lines << ''
File.write(path, lines.join("\n"))
puts "The list of #{found.count} repos saved into #{path}"
2 changes: 1 addition & 1 deletion steps/jpeek-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ done

echo "Analyzed ${repo} through jPeek (${pos}/${total}), \
$(wc -l < "${files}" | xargs) files, \
sum is $(awk '{ sum += $1 } END { print sum }' ${values} | xargs)$("${LOCAL}/help/tdiff.sh" "${start}")"
sum is $(awk '{ sum += $1 } END { print sum }' "${values}" | xargs)$("${LOCAL}/help/tdiff.sh" "${start}")"
2 changes: 1 addition & 1 deletion steps/measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo "${javas}" | while read -r java; do
echo "Metrics already exist for $(basename "${java}") (${file}/${total})"
continue
fi
printf "%s %s %s %s %s\n" ${sh@Q} "${java@Q}" "${javam@Q}" "${file@Q}" "${total@Q}" >> "${jobs}"
printf "%s %s %s %s %s\n" "${sh@Q}" "${java@Q}" "${javam@Q}" "${file@Q}" "${total@Q}" >> "${jobs}"
done

"${LOCAL}/help/parallel.sh" "${jobs}"
Expand Down
4 changes: 2 additions & 2 deletions steps/polish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo "${repos}" | while read -r repo; do
echo "Directory of ${repo} is obsolete and was deleted"
fi
done
echo "All $(echo ${repos} | wc -l | xargs) repo directories inside ${dir} look good"
echo "All $(echo "${repos}" | wc -l | xargs) repo directories inside ${dir} look good"

orgs=$(find "${dir}" -maxdepth 1 -mindepth 1 -type d -exec realpath --relative-to="${dir}" {} \;)
echo "${orgs}" | while read -r org; do
Expand All @@ -48,5 +48,5 @@ echo "${orgs}" | while read -r org; do
echo "Organization ${org} is empty and was deleted"
fi
done
echo "All $(echo ${orgs} | wc -l | xargs) org directories inside ${dir} look good"
echo "All $(echo "${orgs}" | wc -l | xargs) org directories inside ${dir} look good"

1 change: 0 additions & 1 deletion tests/steps/test-aggregate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# SOFTWARE.
set -e
set -o pipefail
set -x

temp=$1

Expand Down
2 changes: 1 addition & 1 deletion tests/steps/test-discover-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ echo "${stdout}" | grep "Found 3 repositories in page 0" >/dev/null
echo "${stdout}" | grep "Found 3 total repositories in GitHub" >/dev/null
test -e "${csv}"
test -e "${tex}"
test $(wc -l < "${csv}" | xargs) = '3'
test $(wc -l < "${csv}" | xargs) = '4'
echo "👍🏻 A few repositories discovered correctly"
4 changes: 2 additions & 2 deletions tests/steps/test-discover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ rm -f "${csv}"
TOTAL=3 "${LOCAL}/steps/discover.sh" >/dev/null
test -e "${csv}"
test -e "${TARGET}/temp/repo-details.tex"
test $(wc -l < "${csv}" | xargs) = '3'
test $(wc -l < "${csv}" | xargs) = '4'
echo "👍🏻 A few repositories discovered correctly"

rm -f "${csv}"
REPO=yegor256/jaxec "${LOCAL}/steps/discover.sh" >/dev/null
test -e "${csv}"
test $(wc -l < "${csv}" | xargs) = '1'
test $(wc -l < "${csv}" | xargs) = '2'
echo "👍🏻 A single repository discovered correctly"

0 comments on commit 0bbf87b

Please sign in to comment.