Skip to content

Commit 2ac1fb9

Browse files
sielayÆndrew Rininsland
authored andcommitted
expose xhr
1 parent 6ed7105 commit 2ac1fb9

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

github.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@
145145
// -------
146146

147147
this.orgs = function(cb) {
148-
_request("GET", '/user/orgs', null, function(err, res) {
149-
cb(err, res);
148+
_request("GET", '/user/orgs', null, function(err, res, xhr) {
149+
cb(err, res, xhr);
150150
});
151151
};
152152

153153
// List authenticated user's gists
154154
// -------
155155

156156
this.gists = function(cb) {
157-
_request("GET", '/gists', null, function(err, res) {
158-
cb(err,res);
157+
_request("GET", '/gists', null, function(err, res, xhr) {
158+
cb(err,res, xhr);
159159
});
160160
};
161161

@@ -196,8 +196,8 @@
196196
if (params.length > 0) {
197197
url += '?' + params.join('&');
198198
}
199-
_request("GET", url, null, function(err, res) {
200-
cb(err,res);
199+
_request("GET", url, null, function(err, res, xhr) {
200+
cb(err,res,xhr);
201201
});
202202
};
203203

@@ -207,8 +207,8 @@
207207
this.show = function(username, cb) {
208208
var command = username ? '/users/' + username : '/user';
209209

210-
_request('GET', command, null, function(err, res) {
211-
cb(err, res);
210+
_request('GET', command, null, function(err, res, xhr) {
211+
cb(err, res, xhr);
212212
});
213213
};
214214

@@ -226,8 +226,8 @@
226226
// -------
227227

228228
this.userGists = function(username, cb) {
229-
_request('GET', '/users/' + username + '/gists', null, function(err, res) {
230-
cb(err,res);
229+
_request('GET', '/users/' + username + '/gists', null, function(err, res, xhr) {
230+
cb(err,res, xhr);
231231
});
232232
};
233233

@@ -316,12 +316,12 @@
316316
// -------
317317

318318
this.getRef = function(ref, cb) {
319-
_request('GET', repoPath + '/git/refs/' + ref, null, function(err, res) {
319+
_request('GET', repoPath + '/git/refs/' + ref, null, function(err, res, xhr) {
320320
if (err) {
321321
return cb(err);
322322
}
323-
324-
cb(null, res.object.sha);
323+
324+
cb(null, res.object.sha, xhr);
325325
});
326326
};
327327

@@ -365,54 +365,54 @@
365365
// -------
366366

367367
this.listTags = function(cb) {
368-
_request('GET', repoPath + '/tags', null, function(err, tags) {
368+
_request('GET', repoPath + '/tags', null, function(err, tags, xhr) {
369369
if (err) {
370370
return cb(err);
371371
}
372-
373-
cb(null, tags);
372+
373+
cb(null, tags, xhr);
374374
});
375375
};
376376

377377
// List all pull requests of a respository
378378
// -------
379379

380380
this.listPulls = function(state, cb) {
381-
_request('GET', repoPath + "/pulls" + (state ? '?state=' + state : ''), null, function(err, pulls) {
381+
_request('GET', repoPath + "/pulls" + (state ? '?state=' + state : ''), null, function(err, pulls, xhr) {
382382
if (err) return cb(err);
383-
cb(null, pulls);
383+
cb(null, pulls, xhr);
384384
});
385385
};
386386

387387
// Gets details for a specific pull request
388388
// -------
389389

390390
this.getPull = function(number, cb) {
391-
_request("GET", repoPath + "/pulls/" + number, null, function(err, pull) {
391+
_request("GET", repoPath + "/pulls/" + number, null, function(err, pull, xhr) {
392392
if (err) return cb(err);
393-
cb(null, pull);
393+
cb(null, pull, xhr);
394394
});
395395
};
396396

397397
// Retrieve the changes made between base and head
398398
// -------
399399

400400
this.compare = function(base, head, cb) {
401-
_request("GET", repoPath + "/compare/" + base + "..." + head, null, function(err, diff) {
401+
_request("GET", repoPath + "/compare/" + base + "..." + head, null, function(err, diff, xhr) {
402402
if (err) return cb(err);
403-
cb(null, diff);
403+
cb(null, diff, xhr);
404404
});
405405
};
406406

407407
// List all branches of a repository
408408
// -------
409409

410410
this.listBranches = function(cb) {
411-
_request("GET", repoPath + "/git/refs/heads", null, function(err, heads) {
411+
_request("GET", repoPath + "/git/refs/heads", null, function(err, heads, xhr) {
412412
if (err) return cb(err);
413413
cb(null, heads.map(function(head) {
414414
return head.ref.replace(/^refs\/heads\//, '');
415-
}));
415+
}), xhr);
416416
});
417417
};
418418

@@ -427,9 +427,9 @@
427427
// -------
428428

429429
this.getCommit = function(branch, sha, cb) {
430-
_request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit) {
430+
_request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit, xhr) {
431431
if (err) return cb(err);
432-
cb(null, commit);
432+
cb(null, commit, xhr);
433433
});
434434
};
435435

@@ -438,19 +438,19 @@
438438

439439
this.getSha = function(branch, path, cb) {
440440
if (!path || path === "") return that.getRef("heads/"+branch, cb);
441-
_request("GET", repoPath + "/contents/" + path + (branch ? "?ref=" + branch : ""), null, function(err, pathContent) {
441+
_request("GET", repoPath + "/contents/" + path + (branch ? "?ref=" + branch : ""), null, function(err, pathContent, xhr) {
442442
if (err) return cb(err);
443-
cb(null, pathContent.sha);
443+
cb(null, pathContent.sha, xhr);
444444
});
445445
};
446446

447447
// Retrieve the tree a commit points to
448448
// -------
449449

450450
this.getTree = function(tree, cb) {
451-
_request("GET", repoPath + "/git/trees/"+tree, null, function(err, res) {
451+
_request("GET", repoPath + "/git/trees/"+tree, null, function(err, res, xhr) {
452452
if (err) return cb(err);
453-
cb(null, res.tree);
453+
cb(null, res.tree, xhr);
454454
});
455455
};
456456

@@ -557,17 +557,17 @@
557557
this.contributors = function (cb, retry) {
558558
retry = retry || 1000;
559559
var self = this;
560-
_request("GET", repoPath + "/stats/contributors", null, function (err, data, response) {
560+
_request("GET", repoPath + "/stats/contributors", null, function (err, data, xhr) {
561561
if (err) return cb(err);
562-
if (response.status === 202) {
562+
if (xhr.status === 202) {
563563
setTimeout(
564564
function () {
565565
self.contributors(cb, retry);
566566
},
567567
retry
568568
);
569569
} else {
570-
cb(err, data);
570+
cb(err, data, xhr);
571571
}
572572
});
573573
};
@@ -651,11 +651,11 @@
651651
// -------
652652

653653
this.read = function(branch, path, cb) {
654-
_request("GET", repoPath + "/contents/"+encodeURI(path) + (branch ? "?ref=" + branch : ""), null, function(err, obj) {
654+
_request("GET", repoPath + "/contents/"+encodeURI(path) + (branch ? "?ref=" + branch : ""), null, function(err, obj, xhr) {
655655
if (err && err.error === 404) return cb("not found", null, null);
656656

657657
if (err) return cb(err);
658-
cb(null, obj);
658+
cb(null, obj, xhr);
659659
}, true);
660660
};
661661

@@ -785,8 +785,8 @@
785785
// --------
786786

787787
this.read = function(cb) {
788-
_request("GET", gistPath, null, function(err, gist) {
789-
cb(err, gist);
788+
_request("GET", gistPath, null, function(err, gist, xhr) {
789+
cb(err, gist, xhr);
790790
});
791791
};
792792

@@ -855,8 +855,8 @@
855855
// --------
856856

857857
this.isStarred = function(cb) {
858-
_request("GET", gistPath+"/star", null, function(err,res) {
859-
cb(err,res);
858+
_request("GET", gistPath+"/star", null, function(err,res, xhr) {
859+
cb(err,res, xhr);
860860
});
861861
};
862862
};

0 commit comments

Comments
 (0)