-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·70 lines (53 loc) · 2.27 KB
/
run.sh
File metadata and controls
executable file
·70 lines (53 loc) · 2.27 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
read -p "Input GitHub Username: " usrname
read -sp "Input GitHub Password: " pssword
while curl -u $usrname:$pssword https://api.github.com | grep -q "Bad credentials"
do
echo "Bad credentials. Please try again (or press ctrl-z to end session)."
read -p "Input GitHub Username: " usrname
read -sp "Input GitHub Password: " pssword
done
read -p "Hello $usrname, input organization: " organization
read -p "Input repository name: " repo
while curl -u $usrname:$pssword https://api.github.com/repos/$organization/$repo | grep -q '"message": "Not Found"'
do
echo "Incorrect organization/repository name. Please try again (or press ctrl-z to end session)."
read -p "Hello $usrname, input organization: " organization
read -p "Input repository name: " repo
done
mkdir $repo
mkdir $repo/data
contributors="https://api.github.com/repos/$organization/$repo/contributors"
branches="https://api.github.com/repos/$organization/$repo/branches"
issues="https://api.github.com/repos/$organization/$repo/issues"
pulls="https://api.github.com/repos/$organization/$repo/pulls?state=all"
curl -u $usrname:$pssword $contributors -o $repo/data/contributors.json $branches -o $repo/data/branches.json $issues -o $repo/data/issues.json $pulls -o $repo/data/pulls.json --progress-bar
grep "name" $repo/data/branches.json | sed 's/"name": "//' | tr -d ' ' | sed 's/..$//' > $repo/data/branches.txt
mkdir $repo/data/commits
while IFS= read LINE
do
mkdir $repo/data/commits/$LINE
i=1
while :
do
curl -u $usrname:$pssword "https://api.github.com/repos/$organization/$repo/commits?page=$i&per_page=100" -o $repo/data/commits/$LINE/commit$i.json
commit=$repo/data/commits/$LINE/commit$i.json
if !(grep -q "sha" $commit) then
rm $repo/data/commits/$LINE/commit$i.json
break
fi
i=$(( $i + 1 ))
done
done < "$repo/data/branches.txt"
#i=1
#while :
#do
# curl -u $usrname:$pssword "https://api.github.com/repos/$organization/$repo/commits?page=$i&per_page=100" -o $repo/data/commits/commit$i.json
# commit=$repo/data/commits/commit$i.json
# if !(grep -q "sha" $commit) then
# rm $repo/data/commits/commit$i.json
# break
# fi
# i=$(( $i + 1 ))
#done
python3.6 main.py $repo $(tput cols)
#cat log.txt