Skip to content

Commit fcc12b3

Browse files
committed
Unified interface for createRef / getRef
1 parent 6c147a4 commit fcc12b3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

github.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134

135135
function updateTree(branch, cb) {
136136
if (branch === currentTree.branch && currentTree.sha) return cb(null, currentTree.sha);
137-
that.getRef(branch, function(err, sha) {
137+
that.getRef("heads/"+branch, function(err, sha) {
138138
currentTree.branch = branch;
139139
currentTree.sha = sha;
140140
cb(err, sha);
@@ -145,7 +145,7 @@
145145
// -------
146146

147147
this.getRef = function(ref, cb) {
148-
_request("GET", repoPath + "/git/refs/heads/" + ref, null, function(err, res) {
148+
_request("GET", repoPath + "/git/refs/" + ref, null, function(err, res) {
149149
if (err) return cb(err);
150150
cb(null, res.object.sha);
151151
});
@@ -195,7 +195,7 @@
195195

196196
this.getSha = function(branch, path, cb) {
197197
// Just use head if path is empty
198-
if (path === "") return that.getRef(branch, cb);
198+
if (path === "") return that.getRef("heads/"+branch, cb);
199199
that.getTree(branch+"?recursive=true", function(err, tree) {
200200
var file = _.select(tree, function(file) {
201201
return file.path === path;
@@ -313,9 +313,7 @@
313313
// -------
314314

315315
this.fork = function(cb) {
316-
_request("POST", repoPath + "/forks", null, function(err, forkedRepo) {
317-
cb(null, forkedRepo);
318-
});
316+
_request("POST", repoPath + "/forks", null, cb);
319317
};
320318

321319
// Create pull request

0 commit comments

Comments
 (0)