-
Notifications
You must be signed in to change notification settings - Fork 0
/
repostree.js
54 lines (40 loc) · 1.55 KB
/
repostree.js
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
var Github = require('github-api'),
Config = require('./config.js'),
d3 = require('d3'),
fs = require('fs');
var github = new Github({
username: Config.username,
password: Config.password,
auth: Config.basic
});
var data = fs.readFileSync('output/orgs_repos/output.tsv','utf8')
data = d3.tsv.parse(data)
var reposNumber = data.length-1,
//var reposNumber = 5,
reposCount = 0;
var getReposTree = function(user, name, default_branch){
var repo = github.getRepo(user, name);
repo.getTree(default_branch + '?recursive=true', function(err, tree) {
if(err){
console.log(reposCount + '/' + reposNumber + ' ' + err)
reposCount = reposCount + 1;
if(reposCount < reposNumber){
getReposTree(data[reposCount].user, data[reposCount].name, data[reposCount].default_branch)
}else{
//writeFinalData(output)
console.log("finished!")
}
}else {
fs.writeFileSync('output/orgs_repos_trees/' + user + '_' + name + '.json', JSON.stringify(tree), 'utf8');
console.log(reposCount + '/' + reposNumber + ' ' + name)
reposCount = reposCount + 1
if(reposCount < reposNumber){
getReposTree(data[reposCount].user, data[reposCount].name, data[reposCount].default_branch)
}else{
//writeFinalData(output)
console.log("finished!")
}
}
});
}
getReposTree(data[reposCount].user, data[reposCount].name, data[reposCount].default_branch)