Skip to content

Commit

Permalink
#85 to-csv
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 2, 2023
1 parent 4902041 commit e9d5dfd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
30 changes: 30 additions & 0 deletions help/to-csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# The MIT License (MIT)
#
# Copyright (c) 2021-2023 Yegor Bugayenko
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -e
set -o pipefail

# Take the STDIN and send it to STDOUT, while making it
# suitable for CSV: replacing commas.

data=$(cat)
printf "${data}" | sed 's/,/\\,/'
2 changes: 1 addition & 1 deletion steps/aggregate-join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ echo "${csvs}" | while IFS= read -r csv; do
if [ ! -e "${join}" ]; then
printf 'repo,%s\n' "${t}" > "${join}"
else
printf '%s,%s\n' "$(echo "${repo}" | sed 's/,/\\,/')" "${t}" >> "${join}"
printf '%s,%s\n' "$(echo "${repo}" | "${LOCAL}/help/to-csv.sh")" "${t}" >> "${join}"
fi
done < "${dir}/${csv}"
done
Expand Down
4 changes: 2 additions & 2 deletions steps/aggregate-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ find "${dir}" -name '*.m' | {
if [ ! -e "${csv}" ]; then
printf 'java_file,%s\n' "${metric}" > "${csv}"
fi
printf '%s,%s\n' "${java//,/\\,}" "$(cat "${v}")" >> "${csv}"
printf '%s,%s\n' "$(echo "${java}" | "${LOCAL}/help/to-csv.sh")" "$(cat "${v}")" >> "${csv}"
done
csv=${ddir}/all.csv
mkdir -p "$(dirname "${csv}")"
Expand All @@ -60,7 +60,7 @@ find "${dir}" -name '*.m' | {
printf '\n' >> "${csv}"
fi
java=$(echo "${m}" | sed "s|${dir}||" | sed "s|\.m$||")
printf '%s' "${java//,/\\,}" >> "${csv}"
printf '%s' "$(echo "${java}" | "${LOCAL}/help/to-csv.sh")" >> "${csv}"
for a in ${all}; do
if [ -e "${m}.${a}" ]; then
value=$("${LOCAL}/help/float.sh" < "${m}.${a}")
Expand Down
7 changes: 6 additions & 1 deletion steps/clone-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ until timeout 1h git clone "${args[@]}" "https://github.com/${repo}" "${dir}"; d
echo "Retry #${re} for ${repo}..."
sleep "${re}"
done
printf "%s,%s\n" "${repo}" "$(git --git-dir "${dir}/.git" rev-parse HEAD)" >> "${TARGET}/hashes.csv"

hashes=${TARGET}/hashes.csv
if [ ! -e "${hashes}" ]; then
printf "repo,hash\n" > "${hashes}"
fi
printf "%s,%s\n" "$(echo "${repo}" | "${LOCAL}/help/to-csv.sh")" "$(git --git-dir "${dir}/.git" rev-parse HEAD)" >> "${hashes}"

echo "${repo} cloned (${pos}/${total}), $(du -sh "${dir}" | cut -f1 | xargs)$("${LOCAL}/help/tdiff.sh" "${start}")"

0 comments on commit e9d5dfd

Please sign in to comment.