|
22 | 22 | if (this.status >= 200 && this.status < 300 || this.status === 304) {
|
23 | 23 | cb(null, raw ? this.responseText : this.responseText ? JSON.parse(this.responseText) : true);
|
24 | 24 | } else {
|
25 |
| - cb(this.status); |
| 25 | + cb({request: this, error: this.status}); |
26 | 26 | }
|
27 | 27 | }
|
28 | 28 | }
|
29 | 29 | xhr.setRequestHeader('Accept','application/vnd.github.raw');
|
30 |
| - xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); |
| 30 | + xhr.setRequestHeader('Content-Type','application/json'); |
31 | 31 | if (
|
32 | 32 | (options.auth == 'oauth' && options.token) ||
|
33 | 33 | (options.auth == 'basic' && options.username && options.password)
|
|
335 | 335 |
|
336 | 336 | this.write = function(branch, path, content, message, cb) {
|
337 | 337 | updateTree(branch, function(err, latestCommit) {
|
| 338 | + if (err) return cb(err); |
338 | 339 | that.postBlob(content, function(err, blob) {
|
| 340 | + if (err) return cb(err); |
339 | 341 | that.updateTree(latestCommit, path, blob, function(err, tree) {
|
| 342 | + if (err) return cb(err); |
340 | 343 | that.commit(latestCommit, tree, message, function(err, commit) {
|
| 344 | + if (err) return cb(err); |
341 | 345 | that.updateHead(branch, commit, cb);
|
342 | 346 | });
|
343 | 347 | });
|
|
0 commit comments