|
95 | 95 | path = next; |
96 | 96 | iterate(); |
97 | 97 | } |
98 | | -<<<<<<< HEAD |
99 | 98 | }); |
100 | 99 | })(); |
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 |
117 | 100 | } |
118 | 101 |
|
119 | 102 |
|
120 | | - |
121 | 103 | // User API |
122 | 104 | // ======= |
123 | 105 |
|
|
220 | 202 | _request("POST", "/user/repos", options, cb); |
221 | 203 | }; |
222 | 204 |
|
223 | | - |
224 | | - |
225 | | - |
226 | | - |
227 | 205 | }; |
228 | 206 |
|
229 | | - |
230 | 207 | // Repository API |
231 | 208 | // ======= |
232 | 209 |
|
|
369 | 346 | // ------- |
370 | 347 |
|
371 | 348 | this.getSha = function(branch, path, cb) { |
372 | | -<<<<<<< HEAD |
373 | | - // Just use head if path is empty |
374 | | - if (path === "") return that.getRef("heads/"+branch, cb); |
375 | | - that.getTree(branch+"?recursive=true", function(err, tree) { |
376 | | - if (err) return cb(err); |
377 | | - var file = _.select(tree, function(file) { |
378 | | - return file.path === path; |
379 | | - })[0]; |
380 | | - cb(null, file ? file.sha : null); |
381 | | -======= |
382 | 349 | if (!path || path === "") return that.getRef("heads/"+branch, cb); |
383 | 350 | _request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) { |
384 | 351 | if (err) return cb(err); |
385 | 352 | cb(null, pathContent.sha); |
386 | | ->>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a |
387 | 353 | }); |
388 | 354 | }; |
389 | 355 |
|
|
497 | 463 | // Get contents |
498 | 464 | // -------- |
499 | 465 |
|
500 | | -<<<<<<< HEAD |
501 | | - this.contents = function(branch, path, cb, sync) { |
502 | | - return _request("GET", repoPath + "/contents?ref=" + branch + (path ? "&path=" + path : ""), null, cb, 'raw', sync); |
503 | | -======= |
504 | 466 | this.contents = function(ref, path, cb) { |
505 | 467 | _request("GET", repoPath + "/contents/"+path, { ref: ref }, cb); |
506 | | ->>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a |
507 | 468 | }; |
508 | 469 |
|
509 | 470 | // Fork repository |
|
581 | 542 | if (err && err.error === 404) return cb("not found", null, null); |
582 | 543 |
|
583 | 544 | if (err) return cb(err); |
584 | | - var sha = obj.sha |
585 | | - , content = Base64.decode(obj.content); |
| 545 | + var sha = obj.sha, |
| 546 | + content = atob(obj.content); |
586 | 547 |
|
587 | 548 | cb(null, content, sha); |
588 | 549 | }); |
|
651 | 612 | if (err && err.error!=404) return cb(err); |
652 | 613 | _request("PUT", repoPath + "/contents/" + path, { |
653 | 614 | message: message, |
654 | | - content: Base64.encode(content), |
| 615 | + content: btoa(content), |
655 | 616 | branch: branch, |
656 | 617 | sha: sha |
657 | 618 | }, cb); |
658 | 619 | }); |
659 | 620 | }; |
660 | 621 |
|
661 | | -<<<<<<< HEAD |
662 | 622 | // List commits on a repository. Takes an object of optional paramaters: |
663 | 623 | // sha: SHA or branch to start listing commits from |
664 | 624 | // path: Only commits containing this file path will be returned |
|
695 | 655 | } |
696 | 656 | _request("GET", url, null, cb); |
697 | 657 | }; |
698 | | -======= |
699 | | ->>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a |
700 | 658 | }; |
701 | 659 |
|
702 | 660 | // Gists API |
|
0 commit comments