From e4f66c8f9500d548201e7c0dd10eb2790889b776 Mon Sep 17 00:00:00 2001 From: Lukasz Sielski Date: Mon, 25 May 2015 01:03:27 +0100 Subject: [PATCH] expose xhr --- github.js | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/github.js b/github.js index 99dc5861..5b458885 100644 --- a/github.js +++ b/github.js @@ -132,8 +132,8 @@ // ------- this.orgs = function(cb) { - _request("GET", '/user/orgs', null, function(err, res) { - cb(err, res); + _request("GET", '/user/orgs', null, function(err, res, xhr) { + cb(err, res, xhr); }); }; @@ -141,8 +141,8 @@ // ------- this.gists = function(cb) { - _request("GET", '/gists', null, function(err, res) { - cb(err,res); + _request("GET", '/gists', null, function(err, res, xhr) { + cb(err,res, xhr); }); }; @@ -150,8 +150,8 @@ // ------- this.notifications = function(cb) { - _request("GET", '/notifications', null, function(err, res) { - cb(err,res); + _request("GET", '/notifications', null, function(err, res, xhr) { + cb(err,res, xhr); }); }; @@ -161,8 +161,8 @@ this.show = function(username, cb) { var command = username ? '/users/' + username : '/user'; - _request('GET', command, null, function(err, res) { - cb(err, res); + _request('GET', command, null, function(err, res, xhr) { + cb(err, res, xhr); }); }; @@ -180,8 +180,8 @@ // ------- this.userGists = function(username, cb) { - _request('GET', '/users/' + username + '/gists', null, function(err, res) { - cb(err,res); + _request('GET', '/users/' + username + '/gists', null, function(err, res, xhr) { + cb(err,res, xhr); }); }; @@ -263,12 +263,12 @@ // ------- this.getRef = function(ref, cb) { - _request('GET', repoPath + '/git/refs/' + ref, null, function(err, res) { + _request('GET', repoPath + '/git/refs/' + ref, null, function(err, res, xhr) { if (err) { return cb(err); } - cb(null, res.object.sha); + cb(null, res.object.sha, xhr); }); }; @@ -312,12 +312,12 @@ // ------- this.listTags = function(cb) { - _request('GET', repoPath + '/tags', null, function(err, tags) { + _request('GET', repoPath + '/tags', null, function(err, tags, xhr) { if (err) { return cb(err); } - cb(null, tags); + cb(null, tags, xhr); }); }; @@ -325,9 +325,9 @@ // ------- this.listPulls = function(state, cb) { - _request('GET', repoPath + "/pulls" + (state ? '?state=' + state : ''), null, function(err, pulls) { + _request('GET', repoPath + "/pulls" + (state ? '?state=' + state : ''), null, function(err, pulls, xhr) { if (err) return cb(err); - cb(null, pulls); + cb(null, pulls, xhr); }); }; @@ -335,9 +335,9 @@ // ------- this.getPull = function(number, cb) { - _request("GET", repoPath + "/pulls/" + number, null, function(err, pull) { + _request("GET", repoPath + "/pulls/" + number, null, function(err, pull, xhr) { if (err) return cb(err); - cb(null, pull); + cb(null, pull, xhr); }); }; @@ -345,9 +345,9 @@ // ------- this.compare = function(base, head, cb) { - _request("GET", repoPath + "/compare/" + base + "..." + head, null, function(err, diff) { + _request("GET", repoPath + "/compare/" + base + "..." + head, null, function(err, diff, xhr) { if (err) return cb(err); - cb(null, diff); + cb(null, diff, xhr); }); }; @@ -355,9 +355,9 @@ // ------- this.listBranches = function(cb) { - _request("GET", repoPath + "/git/refs/heads", null, function(err, heads) { + _request("GET", repoPath + "/git/refs/heads", null, function(err, heads, xhr) { if (err) return cb(err); - cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); })); + cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); }), xhr); }); }; @@ -372,9 +372,9 @@ // ------- this.getCommit = function(branch, sha, cb) { - _request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit) { + _request("GET", repoPath + "/git/commits/"+sha, null, function(err, commit, xhr) { if (err) return cb(err); - cb(null, commit); + cb(null, commit, xhr); }); }; @@ -383,9 +383,9 @@ this.getSha = function(branch, path, cb) { if (!path || path === "") return that.getRef("heads/"+branch, cb); - _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) { + _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent, xhr) { if (err) return cb(err); - cb(null, pathContent.sha); + cb(null, pathContent.sha, xhr); }); }; @@ -393,9 +393,9 @@ // ------- this.getTree = function(tree, cb) { - _request("GET", repoPath + "/git/trees/"+tree, null, function(err, res) { + _request("GET", repoPath + "/git/trees/"+tree, null, function(err, res, xhr) { if (err) return cb(err); - cb(null, res.tree); + cb(null, res.tree, xhr); }); }; @@ -512,7 +512,7 @@ retry ); } else { - cb(err, data); + cb(err, data, response); } }); }; @@ -595,11 +595,11 @@ // ------- this.read = function(branch, path, cb) { - _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, obj) { + _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, obj, xhr) { if (err && err.error === 404) return cb("not found", null, null); if (err) return cb(err); - cb(null, obj); + cb(null, obj, xhr); }, true); }; @@ -729,8 +729,8 @@ // -------- this.read = function(cb) { - _request("GET", gistPath, null, function(err, gist) { - cb(err, gist); + _request("GET", gistPath, null, function(err, gist, xhr) { + cb(err, gist, xhr); }); }; @@ -799,8 +799,8 @@ // -------- this.isStarred = function(cb) { - _request("GET", gistPath+"/star", null, function(err,res) { - cb(err,res); + _request("GET", gistPath+"/star", null, function(err,res, xhr) { + cb(err,res, xhr); }); }; };