+
Skip to content

expose xhr #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions github.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,26 @@
// -------

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);
});
};

// List authenticated user's gists
// -------

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);
});
};

// List authenticated user's unread notifications
// -------

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);
});
};

Expand All @@ -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);
});
};

Expand All @@ -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);
});
};

Expand Down Expand Up @@ -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);
});
};

Expand Down Expand Up @@ -312,52 +312,52 @@
// -------

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);
});
};

// List all pull requests of a respository
// -------

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);
});
};

// Gets details for a specific pull request
// -------

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);
});
};

// Retrieve the changes made between base and head
// -------

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);
});
};

// List all branches of a repository
// -------

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);
});
};

Expand All @@ -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);
});
};

Expand All @@ -383,19 +383,19 @@

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);
});
};

// Retrieve the tree a commit points to
// -------

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);
});
};

Expand Down Expand Up @@ -512,7 +512,7 @@
retry
);
} else {
cb(err, data);
cb(err, data, response);
}
});
};
Expand Down Expand Up @@ -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);
};

Expand Down Expand Up @@ -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);
});
};

Expand Down Expand Up @@ -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);
});
};
};
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载