-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_all_repositories.sh
executable file
·51 lines (44 loc) · 1.91 KB
/
compute_all_repositories.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -ue
cd "$(dirname "$0")"
cd repositories
statistics="../statistics"
mkdir -p "$statistics"
for repos in */; do
repos=${repos%?}
echo "Computing posix-count for $repos"
if [ ! -f "$statistics/$repos.posix" ]; then
grep -REhIoe "$(cut -f3 ../posix_functions)" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc" --include="*.cpp" --include="*.cxx" "$repos"|cut -d"(" -f1|awk '{$1=$1};1'|sort|uniq -c > "$statistics/$repos.posix"
else
echo "$statistics/$repos.posix exists; skipping"
fi
oldbranch=$(cd "$repos" && git rev-parse --abbrev-ref HEAD)
echo "Remembered $oldbranch for later checkout"
echo "Computing 5-years ago posix for $repos"
fiveyearbranch=$(cd "$repos" && git rev-list -n 1 --before="2013-08-20 00:00" HEAD)
if [ -n "$fiveyearbranch" ]; then
if [ ! -f "$statistics/$repos.5years.posix" ]; then
$(cd "$repos" && git checkout "$fiveyearbranch")
grep -REhIoe "$(cut -f3 ../posix_functions)" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc" --include="*.cpp" --include="*.cxx" "$repos"|cut -d"(" -f1|awk '{$1=$1};1'|sort|uniq -c > "$statistics/$repos.5years.posix"
else
echo "$statistics/$repos.5years.posix exists; skipping"
fi
else
echo "No commit from 5 years ago."
fi
echo "Computing 10-years ago posix for $repos"
tenyearbranch=$(cd "$repos" && git rev-list -n 1 --before="2008-08-20 00:00" HEAD)
if [ -n "$tenyearbranch" ]; then
if [ ! -f "$statistics/$repos.10years.posix" ]; then
$(cd "$repos" && git checkout "$tenyearbranch")
grep -REhIoe "$(cut -f3 ../posix_functions)" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc" --include="*.cpp" --include="*.cxx" "$repos"|cut -d"(" -f1|awk '{$1=$1};1'|sort|uniq -c > "$statistics/$repos.10years.posix"
else
echo "$statistics/$repos.10years.posix exists; skipping"
fi
else
echo "No commit from 10 years ago."
fi
cd "$repos"
git checkout "$oldbranch"
cd ..
done