-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_to_csv.sh
executable file
·49 lines (28 loc) · 1.03 KB
/
git_to_csv.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
#!/bin/bash
#output csv of git log, one line for each file/commit combination
begin_date="2012-1-29"
end_date="2014-4-29"
echo "file_change_type,filename,commit,author,date,description,patch_overview"
gitcsv=$(git log --before=$end_date --after=$begin_date --no-merges --name-status --pretty=format:'%H,%an,%ad,"%s"'|tr '\t' ',')
declare -a commitarray
bigcount=0
echo "$gitcsv"|while read line;do
if [ -z "$line" ];then
count=1
commit=`echo "${commitarray[0]}"|cut -d, -f1`
while [ $count -lt ${#commitarray[@]} ];do
filename=`echo "${commitarray[$count]}"|cut -d, -f2`
diff=`git diff --no-color ${commit} ${commit}^ -- "${filename}"|grep '^@@'|sed -n 's/^.*@@.*-\(.*\) +\(.*\) @@.*$/-\1 +\2/p'|tr '\n' '|'`
if [ -z "$diff" ];then
diff="Binary Changes."
fi
echo "${commitarray[$count]},${commitarray[0]},\"${diff}\""
let count=count+1
done
commitarray=()
bigcount=0
else
commitarray[$bigcount]="$line"
let bigcount=bigcount+1
fi
done|sed 's/|"$/"/'