-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_scraper.sh
More file actions
52 lines (44 loc) · 1.32 KB
/
git_scraper.sh
File metadata and controls
52 lines (44 loc) · 1.32 KB
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 -x
file_directory="/d/mids/ai_bug_detector/Closed_PR_files"
git_repo="/d/mids/matplotlib"
output_directory="/d/mids/real_parsed_data"
output_file="${output_directory}/jeff_is_the_realone.txt"
declare -a filePathList
declare -a fileList
fileList+=( "$( ls ${file_directory}/Closed_PR*.txt)" )
mkdir -p ${output_directory}
cd ${git_repo}
for file in ${fileList[@]}; do
cd ${file_directory}
#echo "Current Dir: $(pwd)"
#echo "file = ${file}"
#read -p pause
for hash in $(cat ${file} | tr ' ' '\n' ) ; do
cd ${git_repo}
git clean -ff
sleep 1
mkdir -p ${output_directory}/${hash}
#read -p pause
printf "================================\n" >> ${output_file}
printf "Hash Commit: %s\n" ${hash} >> ${output_file}
git checkout -f ${hash}
git diff HEAD^-1 --name-only >> ${output_directory}/temp_${hash}
cat ${output_directory}/temp_${hash} | tee -a ${output_file}
filePathList=( $(cat ${output_directory}/temp_${hash}) )
#read -p pause
for diff_file in ${filePathList[@]}; do
file_name=$(basename ${diff_file})
cp ${diff_file} ${output_directory}/${hash}/${hash}_${file_name}
done
rm ${output_directory}/temp_${hash}
git switch -
git clean -ff
sleep 1
done
done
cleanup(){
unset file_directory git_repo output_directory output_file
unset filePathList fileList
rm -rf ${output_directory}
}