-
Notifications
You must be signed in to change notification settings - Fork 31
/
update_readme.sh
executable file
·237 lines (224 loc) · 7.03 KB
/
update_readme.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/bash
folder_location="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
date=$(date %m-%d-%Y)
lastweek=$(date +%m-%d-%Y -d "$date - 7 day")
echo $lastweek
echo $date
cd "projects"
declare -A count
declare -A count_week
declare -A count_all
declare -A count_all_week
verified_bugs=0
all_bugs=0
add=1
my_function () {
#pass_all=$(find bugs/* -maxdepth 0 -type d 2>&1 | wc -l)
dirs=($(find bugs/* -maxdepth 0 -type d))
for dir in "${dirs[@]}"; do
bug_location="$temp_location/$dir"
cd $bug_location
check_name_all=$(git shortlog -sn requirements.txt 2>&1 | head -n 1)
if [[ $check_name_all == "fatal: "* ]]; then
check_name_all=$(git shortlog -sn run_test.sh 2>&1 | head -n 1)
fi
if [[ $check_name_all == "fatal: "* ]]; then
check_name_all=$(git shortlog -sn bug.info 2>&1 | head -n 1)
fi
if [[ $check_name_all == "fatal: "* ]]; then
check_name_all=""
fi
only_name="${check_name_all#* }"
if [[ $only_name != "" ]]; then
#echo "PRINT NAME"
#echo $only_name
all_bugs=$((all_bugs + add))
if [[ ${count_all[only_name]+abc} == "abc" ]]; then
temp=count_all[$only_name]
#echo "$temp"
num=$((temp + add))
count_all[$only_name]=$num
else
temp=count_all[$only_name]
num=$((temp + add))
count_all[$only_name]=$num
fi
fi
pwd
check_name_all_week=$(git shortlog -sn --since="$lastweek" requirements.txt 2>&1 | head -n 1)
if [[ $check_name_all_week == "fatal: "* ]]; then
check_name_all_week=$(git shortlog -sn --since="$lastweek" run_test.sh 2>&1 | head -n 1)
fi
if [[ $check_name_all_week == "fatal: "* ]]; then
check_name_all_week=$(git shortlog -sn --since="$lastweek" bug.info 2>&1 | head -n 1)
fi
if [[ $check_name_all_week == "fatal: "* ]]; then
check_name_all_week=""
fi
only_name="${check_name_all_week#* }"
if [[ $only_name != "" ]]; then
#echo "PRINT NAME WEEK"
#echo $only_name
if [[ ${count_all_week[only_name]+abc} == "abc" ]]; then
temp=count_all_week[$only_name]
#echo "$temp"
num=$((temp + add))
count_all_week[$only_name]=$num
else
temp=count_all_week[$only_name]
num=$((temp + add))
count_all_week[$only_name]=$num
fi
fi
done
cd $temp_location
if [[ -f "$var-pass.txt" ]]; then
pass=0
pass_all=0
check=0
logAll=""
DONE=false
until $DONE ;do
read || DONE=true
if [[ "$REPLY" != "PASS:"* && "$REPLY" != "" ]]; then
echo "$REPLY"
folder="$(cut -d'(' -f 1 <<< $REPLY)"
echo "$folder"
string2="${folder##*/}"
string3="$(cut -d' ' -f 1 <<< $string2)"
if [[ $logAll != *";$string3;"* ]]; then
if [[ $logAll != "$string3;" ]]; then
logAll+="$string3;"
check=$((check+add))
echo "$string3"
fi
fi
fi
done < "$var-pass.txt"
echo "$check"
IFS=';' read -r -a log <<< "$logAll"
for index in "${log[@]}"
do
echo "$index"
check_name=$(git shortlog -sn "bugs/$index/run_test.sh" 2>&1 | head -n 1)
if [[ $check_name == "fatal: "* ]]; then
check_name=$(git shortlog -sn "bugs/$index/requirements.txt" 2>&1 | head -n 1)
fi
if [[ $check_name == "fatal: "* ]]; then
check_name=$(git shortlog -sn "bugs/$index/bug.info" 2>&1 | head -n 1)
fi
if [[ $check_name == "fatal: "* ]]; then
check_name=""
fi
if [[ $check_name != "" ]]; then
only_name="${check_name#* }"
#echo "$only_name"
temp=count[$only_name]
#echo "$temp"
num=$((temp + add))
count[$only_name]=$num
pass_all=$((pass_all + add))
#echo "$num"
#echo "$pass_all"
fi
check_name=$(git shortlog -sn --since="$lastweek" "bugs/$index/run_test.sh" 2>&1 | head -n 1)
if [[ $check_name == "fatal: "* ]]; then
check_name=$(git shortlog -sn --since="$lastweek" "bugs/$index/requirements.txt" 2>&1 | head -n 1)
fi
if [[ $check_name == "fatal: "* ]]; then
check_name=$(git shortlog -sn --since="$lastweek" "bugs/$index/bug.info" 2>&1 | head -n 1)
fi
if [[ $check_name == "fatal: "* ]]; then
check_name=""
fi
#echo "$check_name"
if [[ $check_name != "" ]]; then
only_name="${check_name#* }"
temp=count_week[$only_name]
#echo "$temp"
num=$((temp + add))
count_week[$only_name]=$num
pass=$((pass + add))
fi
done
verified_bugs=$((verified_bugs + pass_all))
fi
}
dirs=($(find . -maxdepth 1 -type d))
for dir in "${dirs[@]}"; do
if [[ "$dir" != "." ]]; then
var="$(cut -d'/' -f 2 <<< $dir)"
temp_location="$folder_location/projects/$var"
cd "$temp_location"
pwd
my_function
fi
done
cd $folder_location
for index in "${!count[@]}"
do
temp=${count[$index]}
temp2=$index
echo "$temp $temp2"
done
countAll=""
for index in "${!count_all[@]}"
do
temp=${count_all[$index]}
temp2=$index
countAll+="$temp:$temp2;"
done
echo "$countAll"
IFS=';' read -r -a count_fix <<< "$countAll"
IFS=$'\n' sorted=($(sort -n -r <<<"${count_fix[*]}")); unset IFS
countAllWeek=""
for index in "${!count_all_week[@]}"
do
temp=${count_all_week[$index]}
temp2=$index
countAllWeek+="$temp:$temp2;"
done
IFS=';' read -r -a count_fix_week <<< "$countAllWeek"
IFS=$'\n' sorted_week=($(sort -n -r <<<"${count_fix_week[*]}")); unset IFS
echo "# BugsInPy" > README.md
echo "BugsInPy: Benchmarking Bugs in Python Projects" >> README.md
echo "## Top 3 Contributors (of all time)" >> README.md
echo "Name | Bugs Data | Verified Bugs Data" >> README.md
echo "--- | --- | --- " >> README.md
maxNumber=3
now=0
for index in "${sorted[@]}"
do
if [[ $now != $maxNumber ]]; then
string1="$(cut -d':' -f 1 <<< $index)"
string2="${index#*:}"
string3="${count[$string2]}"
string3=$((string3 + 0))
echo "$string1"
echo "$string2"
echo "$string3"
echo "$string2 | $string1 | $string3" >> README.md
now=$((now+add))
fi
done
echo "## Top 3 Contributors (last week)" >> README.md
echo "Name | Bugs Data | Verified Bugs Data" >> README.md
echo "--- | --- | --- " >> README.md
maxNumber=3
now=0
for index in "${sorted_week[@]}"
do
if [[ $now != $maxNumber ]]; then
string1="$(cut -d':' -f 1 <<< $index)"
string2="${index#*:}"
echo "$string1"
echo "$string2"
string3="${count_week[$string2]}"
string3=$((string3 + 0))
echo "$string2 | $string1 | $string3" >> README.md
now=$((now+add))
fi
done
echo "#### Total data : $all_bugs" >> README.md
echo "#### Total verified bugs data : $verified_bugs" >> README.md
echo "###### Note: this list is based on the dataset bug without verifying the data. We will update this list of contributors based on the output of verify.sh that you pushed on the repo." >> README.md