|
16 | 16 | // Initial Setup |
17 | 17 | // ------------- |
18 | 18 |
|
19 | | - var XMLHttpRequest, _, btoa; |
| 19 | + var XMLHttpRequest, btoa; |
20 | 20 | /* istanbul ignore else */ |
21 | 21 | if (typeof exports !== 'undefined') { |
22 | 22 | XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; |
23 | | - _ = require('underscore'); |
24 | 23 | if (typeof btoa === 'undefined') { |
25 | 24 | btoa = require('btoa'); //jshint ignore:line |
26 | 25 | } |
27 | 26 | } else { |
28 | | - _ = window._; |
29 | 27 | btoa = window.btoa; |
30 | 28 | } |
31 | 29 |
|
|
50 | 48 | var url = path.indexOf('//') >= 0 ? path : API_URL + path; |
51 | 49 | url += ((/\?/).test(url) ? '&' : '?'); |
52 | 50 | // Fix #195 about XMLHttpRequest.send method and GET/HEAD request |
53 | | - if (_.isObject(data) && _.indexOf(['GET', 'HEAD'], method) > -1) { |
54 | | - url += '&' + _.map(data, function (v, k) { |
55 | | - return k + '=' + v; |
| 51 | + if (data && typeof data === "object" && ['GET', 'HEAD'].indexOf(method) > -1) { |
| 52 | + url += '&' + Object.keys(data).map(function (k) { |
| 53 | + return k + '=' + data[k]; |
56 | 54 | }).join('&'); |
57 | 55 | } |
58 | 56 | return url + '&' + (new Date()).getTime(); |
|
107 | 105 | results.push.apply(results, res); |
108 | 106 |
|
109 | 107 | var links = (xhr.getResponseHeader('link') || '').split(/\s*,\s*/g), |
110 | | - next = _.find(links, function(link) { return /rel="next"/.test(link); }); |
| 108 | + next = null; |
| 109 | + links.forEach(function(link) { |
| 110 | + next = /rel="next"/.test(link) ? link : next; |
| 111 | + }); |
111 | 112 |
|
112 | 113 | if (next) { |
113 | 114 | next = (/<(.*)>/.exec(next) || [])[1]; |
|
364 | 365 | this.listBranches = function(cb) { |
365 | 366 | _request("GET", repoPath + "/git/refs/heads", null, function(err, heads) { |
366 | 367 | if (err) return cb(err); |
367 | | - cb(null, _.map(heads, function(head) { return _.last(head.ref.split('/')); })); |
| 368 | + cb(null, heads.map(function(head) { |
| 369 | + var headParts = head.ref.split('/'); |
| 370 | + return headParts[headParts.length - 1]; |
| 371 | + })); |
368 | 372 | }); |
369 | 373 | }; |
370 | 374 |
|
|
651 | 655 | updateTree(branch, function(err, latestCommit) { |
652 | 656 | that.getTree(latestCommit+"?recursive=true", function(err, tree) { |
653 | 657 | // Update Tree |
654 | | - _.each(tree, function(ref) { |
| 658 | + tree.forEach(function(ref) { |
655 | 659 | if (ref.path === path) ref.path = newPath; |
656 | 660 | if (ref.type === "tree") delete ref.sha; |
657 | 661 | }); |
|
0 commit comments