Commit 34470799 authored by Agustin Benito Bethencourt's avatar Agustin Benito Bethencourt

Merge branch 'valentindavid/statistics-tools' into 'master'

Add scripts generating stat data from some BuildStream repositories

See merge request !4
parents c4bb081b da868a8c
#!/bin/bash
. common.sh
remote=https://gitlab.com/BuildStream/bst-external.git
git clone "${remote}" "${tmpdir}"
cd "${tmpdir}"
CLOCK_OPTIONS=""
scan_commits bst_external:code doc tests
#!/bin/bash
. common.sh
remote=https://gitlab.com/BuildStream/buildstream.git
git clone "${remote}" "${tmpdir}"
cd "${tmpdir}"
CLOCK_OPTIONS="--exclude-dir=_protos"
scan_commits buildstream:code doc tests
set -eu
tmpdir="$(mktemp --tmpdir -d git-stat.XXXXXXXXXX)"
cleanup() {
rm -rf "${tmpdir}"
}
trap cleanup EXIT
clocdir() {
files=0
blank=0
comment=0
code=0
if ! [ -d "${1}" ]; then
echo -n "0,0,0,0"
return
fi
for language in $(cloc ${CLOCK_OPTIONS} --quiet --csv "${1}" | sed "1d;2d" | cut -d, -f1,3-); do
files="$(("${files}"+"$(echo "${language}" | cut -d, -f1)"))"
blank="$(("${blank}"+"$(echo "${language}" | cut -d, -f2)"))"
comment="$(("${comment}"+"$(echo "${language}" | cut -d, -f3)"))"
code="$(("${code}"+"$(echo "${language}" | cut -d, -f4)"))"
done
echo -n "${files},${blank},${comment},${code}"
}
scan_commits () {
echo -n "commit,date,authors"
if [ "$#" -lt 2 ]; then
echo ",files,blank,comment,code"
else
for dir in "[email protected]"; do
dir="$(echo "${dir}" | sed 's/.*://')"
echo -n ",${dir}-files,${dir}-blank,${dir}-comment,${dir}-code"
done
echo ""
fi
for commit in $(git log --first-parent --format=%H); do
git checkout "${commit}"
case "$(git log -1 --format=%P "${commit}" | wc -w)" in
1)
commits="-1 ${commit}^"
;;
2)
base="$(git merge-base "${commit}^" "${commit}^2")"
commits="${base}..${commit}^2"
;;
*)
echo "Unexpected number of parents for ${commit}" 1>&2
exit 1
;;
esac
authors="$(git log --format="%ae" ${commits} | sort -u | sed ':l;N;s/\n/:/;bl')"
date="$(git log -1 --format="%ct" "${commit}")"
echo -n "${commit},${date},${authors}"
for dir in "[email protected]"; do
dir="$(echo "${dir}" | sed 's/:.*//')"
echo -n ","
clocdir "${dir}"
done
echo ""
done
}
#!/bin/bash
. common.sh
remote=https://gitlab.com/BuildStream/website.git
git clone "${remote}" "${tmpdir}"
cd "${tmpdir}"
CLOCK_OPTIONS="--exclude-dir='.*theme'"
scan_commits .
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment