forked from GitStarInc/git-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
36 lines (33 loc) · 945 Bytes
/
example.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
"use strict";
var Gitstar = require('./index');
var repo = new Gitstar(
{
url: "https://api.github.com",
repo: "node",
repoPrefix: '/repos/joyent/:repo/git/',
cb: function (data) { console.log(data); }
});
repo.getRefs(function(data) {
console.log(data);
var json = JSON.parse(data);
for (var i=0; i < json.length; i++) {
if (json[i].object) {
switch(json[i].object.type) {
case 'commit':
repo.getCommit(json[i].object.sha);
break;
case 'blob':
repo.getBlob(json[i].object.sha);
break;
case 'tag':
repo.getTag(json[i].object.sha);
break;
case 'tree':
repo.getTree(json[i].object.sha);
break;
default:
break;
}
}
}
});