forked from gilesbowkett/rewind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_stats.sh
50 lines (41 loc) · 936 Bytes
/
file_stats.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
function git_history {
git log $filename | grep "Date: "
}
function first_commit {
git_history | tail -1
}
function last_commit {
git_history | head -1
}
function number_of_commits {
git_history | wc -l
}
function legible_output {
# $2: filename
# $1: lines of code
# $3: number of commits
# $6: month (first)
# $7: date (first)
# $9: year (first)
# $13: month (last)
# $14: date (last)
# $16: year (last)
awk '{print $2 "," $1 "," $3 "," $6 " " $7 " " $9 "," $13 " " $14 " " $16}'
}
function csv_lines_for {
for filename in $(find . -iname "*.$1"); do
echo "`wc -l $filename` `number_of_commits` `first_commit` `last_commit`" |
legible_output |
xargs echo
done
}
function create_csv {
echo "filename,lines of code,number of commits,date of first commit,date of last commit"
for argument in "$@"
do
csv_lines_for $argument
done
}
cd $1
create_csv $@
cd -