Skip to content

Commit c74ed59

Browse files
committed
Browser List
2 parents 71a3cb7 + c75337c commit c74ed59

File tree

2 files changed

+84
-91
lines changed

2 files changed

+84
-91
lines changed

github.js

Lines changed: 76 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,25 @@
9595
path = next;
9696
iterate();
9797
}
98+
<<<<<<< HEAD
9899
});
99100
})();
101+
=======
102+
}
103+
};
104+
xhr.setRequestHeader('Accept','application/json');
105+
xhr.setRequestHeader('Content-Type','application/json');
106+
if (
107+
(options.auth == 'oauth' && options.token) ||
108+
(options.auth == 'basic' && options.username && options.password)
109+
) {
110+
xhr.setRequestHeader('Authorization',options.auth == 'oauth'
111+
? 'token '+ options.token
112+
: 'Basic ' + Base64.encode(options.username + ':' + options.password)
113+
);
114+
}
115+
data ? xhr.send(JSON.stringify(data)) : xhr.send();
116+
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
100117
}
101118

102119

@@ -196,6 +213,17 @@
196213
cb(err, res);
197214
});
198215
};
216+
217+
// Create a repo
218+
// -------
219+
this.createRepo = function(options, cb) {
220+
_request("POST", "/user/repos", options, cb);
221+
};
222+
223+
224+
225+
226+
199227
};
200228

201229

@@ -214,6 +242,14 @@
214242
"sha": null
215243
};
216244

245+
246+
// Delete a repo
247+
// --------
248+
249+
this.deleteRepo = function(cb) {
250+
_request("DELETE", repoPath, options, cb);
251+
};
252+
217253
// Uses the cache if branch has not been changed
218254
// -------
219255

@@ -333,6 +369,7 @@
333369
// -------
334370

335371
this.getSha = function(branch, path, cb) {
372+
<<<<<<< HEAD
336373
// Just use head if path is empty
337374
if (path === "") return that.getRef("heads/"+branch, cb);
338375
that.getTree(branch+"?recursive=true", function(err, tree) {
@@ -341,6 +378,12 @@
341378
return file.path === path;
342379
})[0];
343380
cb(null, file ? file.sha : null);
381+
=======
382+
if (!path || path === "") return that.getRef("heads/"+branch, cb);
383+
_request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) {
384+
if (err) return cb(err);
385+
cb(null, pathContent.sha);
386+
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
344387
});
345388
};
346389

@@ -454,8 +497,13 @@
454497
// Get contents
455498
// --------
456499

500+
<<<<<<< HEAD
457501
this.contents = function(branch, path, cb, sync) {
458502
return _request("GET", repoPath + "/contents?ref=" + branch + (path ? "&path=" + path : ""), null, cb, 'raw', sync);
503+
=======
504+
this.contents = function(ref, path, cb) {
505+
_request("GET", repoPath + "/contents/"+path, { ref: ref }, cb);
506+
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
459507
};
460508

461509
// Fork repository
@@ -529,34 +577,29 @@
529577
// -------
530578

531579
this.read = function(branch, path, cb) {
532-
that.getSha(branch, path, function(err, sha) {
533-
if (!sha) return cb("not found", null);
534-
that.getBlob(sha, function(err, content) {
535-
cb(err, content, sha);
536-
});
580+
_request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, obj) {
581+
if (err && err.error === 404) return cb("not found", null, null);
582+
583+
if (err) return cb(err);
584+
var sha = obj.sha
585+
, content = Base64.decode(obj.content);
586+
587+
cb(null, content, sha);
537588
});
538589
};
539590

540-
// Remove a file from the tree
591+
592+
// Remove a file
541593
// -------
542594

543595
this.remove = function(branch, path, cb) {
544-
updateTree(branch, function(err, latestCommit) {
545-
that.getTree(latestCommit+"?recursive=true", function(err, tree) {
546-
// Update Tree
547-
var newTree = _.reject(tree, function(ref) { return ref.path === path; });
548-
_.each(newTree, function(ref) {
549-
if (ref.type === "tree") delete ref.sha;
550-
});
551-
552-
that.postTree(newTree, function(err, rootTree) {
553-
that.commit(latestCommit, rootTree, 'Deleted '+path , function(err, commit) {
554-
that.updateHead(branch, commit, function(err) {
555-
cb(err);
556-
});
557-
});
558-
});
559-
});
596+
that.getSha(branch, path, function(err, sha) {
597+
if (err) return cb(err);
598+
_request("DELETE", repoPath + "/contents/" + path, {
599+
message: path + " is removed",
600+
sha: sha,
601+
branch: branch
602+
}, cb);
560603
});
561604
};
562605

@@ -604,21 +647,18 @@
604647
// -------
605648

606649
this.write = function(branch, path, content, message, cb) {
607-
updateTree(branch, function(err, latestCommit) {
608-
if (err) return cb(err);
609-
that.postBlob(content, function(err, blob) {
610-
if (err) return cb(err);
611-
that.updateTree(latestCommit, path, blob, function(err, tree) {
612-
if (err) return cb(err);
613-
that.commit(latestCommit, tree, message, function(err, commit) {
614-
if (err) return cb(err);
615-
that.updateHead(branch, commit, cb);
616-
});
617-
});
618-
});
650+
that.getSha(branch, path, function(err, sha) {
651+
if (err && err.error!=404) return cb(err);
652+
_request("PUT", repoPath + "/contents/" + path, {
653+
message: message,
654+
content: Base64.encode(content),
655+
branch: branch,
656+
sha: sha
657+
}, cb);
619658
});
620659
};
621660

661+
<<<<<<< HEAD
622662
// List commits on a repository. Takes an object of optional paramaters:
623663
// sha: SHA or branch to start listing commits from
624664
// path: Only commits containing this file path will be returned
@@ -655,6 +695,8 @@
655695
}
656696
_request("GET", url, null, cb);
657697
};
698+
=======
699+
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
658700
};
659701

660702
// Gists API

package.json

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -36,63 +36,14 @@
3636
"testling": {
3737
"files": "test/test.*.js",
3838
"browsers": [
39-
"iexplore/10.0",
40-
"iexplore/9.0",
41-
"chrome/6.0",
42-
"chrome/7.0",
43-
"chrome/8.0",
44-
"chrome/9.0",
45-
"chrome/10.0",
46-
"chrome/11.0",
47-
"chrome/12.0",
48-
"chrome/13.0",
49-
"chrome/14.0",
50-
"chrome/15.0",
51-
"chrome/16.0",
52-
"chrome/17.0",
53-
"chrome/18.0",
54-
"chrome/19.0",
55-
"chrome/20.0",
56-
"chrome/21.0",
57-
"chrome/22.0",
58-
"chrome/23.0",
59-
"chrome/24.0",
60-
"chrome/25.0",
61-
"firefox/3.0",
62-
"firefox/3.5",
63-
"firefox/3.6",
64-
"firefox/4.0",
65-
"firefox/5.0",
66-
"firefox/6.0",
67-
"firefox/7.0",
68-
"firefox/8.0",
69-
"firefox/9.0",
70-
"firefox/10.0",
71-
"firefox/11.0",
72-
"firefox/12.0",
73-
"firefox/13.0",
74-
"firefox/14.0",
75-
"firefox/15.0",
76-
"firefox/16.0",
77-
"firefox/17.0",
78-
"firefox/18.0",
79-
"firefox/19.0",
80-
"opera/10.0",
81-
"opera/10.5",
82-
"opera/11.0",
83-
"opera/11.5",
84-
"opera/11.6",
85-
"opera/12.0",
86-
"safari/4.0",
87-
"safari/5.0.5",
88-
"safari/5.1",
89-
"firefox/nightly",
90-
"opera/next",
91-
"chrome/canary",
92-
"iphone/6.0",
93-
"ipad/6.0",
94-
"safari/6.0",
95-
"android-browser/4.2"
39+
"iexplore/9.0..latest",
40+
"chrome/18.0..latest",
41+
"firefox/15.0..latest",
42+
"opera/11.0..latest",
43+
"safari/5.0.5..latest",
44+
"iphone/6.0..latest",
45+
"ipad/6.0..latest",
46+
"android-browser/4.2..latest"
9647
]
9748
}
9849
}

0 commit comments

Comments
 (0)