Skip to content

Commit af1e5b5

Browse files
committed
Update Tests and fix merge conflicts
1 parent c74ed59 commit af1e5b5

File tree

3 files changed

+61
-51
lines changed

3 files changed

+61
-51
lines changed

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ Show repository information
6363
repo.show(function(err, repo) {});
6464
```
6565

66+
Delete a repository
67+
68+
```js
69+
repo.deleteRepo(function(err, res) {});
70+
```
71+
6672
Get contents at a particular path in a particular branch. Set sync to true to get contents via sync method.
6773

6874
```js
@@ -78,7 +84,7 @@ repo.fork(function(err) {});
7884
Create new branch for repo. You can omit oldBranchName to default to "master".
7985

8086
```js
81-
repo.branch(oldBranchName, newBranchName, function(err) {});
87+
repo.branch(oldBranchName, newBranchName, function(err) {});
8288
```
8389

8490
Create Pull Request.
@@ -208,6 +214,15 @@ List public repositories for a particular user.
208214
user.userRepos(username, function(err, repos) {});
209215
```
210216

217+
Create a new repo for the authenticated user
218+
219+
```js
220+
user.createRepo({"name": "test"}, function(err, res) {});
221+
```
222+
Repo description, homepage, private/public can also be set.
223+
For a full list of options see the docs [here](https://developer.github.com/v3/repos/#create)
224+
225+
211226
List repositories for a particular organization. Includes private repositories if you are authorized.
212227

213228
```js
@@ -234,7 +249,7 @@ gist.read(function(err, gist) {
234249
});
235250
```
236251

237-
Updating the contents of a Gist. Please consult the documentation on [GitHub](http://developer.github.com/v3/gists/).
252+
Updating the contents of a Gist. Please consult the documentation on [GitHub](http://developer.github.com/v3/gists/).
238253

239254
```js
240255
var delta = {
@@ -255,7 +270,7 @@ var delta = {
255270
};
256271

257272
gist.update(delta, function(err, gist) {
258-
273+
259274
});
260275
```
261276
## Issues API
@@ -264,7 +279,7 @@ gist.update(delta, function(err, gist) {
264279
var issues = github.getIssues(username, reponame);
265280
```
266281

267-
To read all the issues of a given repository
282+
To read all the issues of a given repository
268283

269284
```js
270285
issues.list(options, function(err, issues) {});
@@ -313,7 +328,7 @@ Adds support for organizations and fixes an encoding issue.
313328

314329
### 0.5.X
315330

316-
Smart caching of latest commit sha.
331+
Smart caching of latest commit sha.
317332

318333
### 0.4.X
319334

github.js

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,11 @@
9595
path = next;
9696
iterate();
9797
}
98-
<<<<<<< HEAD
9998
});
10099
})();
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
117100
}
118101

119102

120-
121103
// User API
122104
// =======
123105

@@ -220,13 +202,8 @@
220202
_request("POST", "/user/repos", options, cb);
221203
};
222204

223-
224-
225-
226-
227205
};
228206

229-
230207
// Repository API
231208
// =======
232209

@@ -369,21 +346,10 @@
369346
// -------
370347

371348
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-
=======
382349
if (!path || path === "") return that.getRef("heads/"+branch, cb);
383350
_request("GET", repoPath + "/contents/"+path, {ref: branch}, function(err, pathContent) {
384351
if (err) return cb(err);
385352
cb(null, pathContent.sha);
386-
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
387353
});
388354
};
389355

@@ -497,13 +463,8 @@
497463
// Get contents
498464
// --------
499465

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-
=======
504466
this.contents = function(ref, path, cb) {
505467
_request("GET", repoPath + "/contents/"+path, { ref: ref }, cb);
506-
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
507468
};
508469

509470
// Fork repository
@@ -581,8 +542,8 @@
581542
if (err && err.error === 404) return cb("not found", null, null);
582543

583544
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);
586547

587548
cb(null, content, sha);
588549
});
@@ -651,14 +612,13 @@
651612
if (err && err.error!=404) return cb(err);
652613
_request("PUT", repoPath + "/contents/" + path, {
653614
message: message,
654-
content: Base64.encode(content),
615+
content: btoa(content),
655616
branch: branch,
656617
sha: sha
657618
}, cb);
658619
});
659620
};
660621

661-
<<<<<<< HEAD
662622
// List commits on a repository. Takes an object of optional paramaters:
663623
// sha: SHA or branch to start listing commits from
664624
// path: Only commits containing this file path will be returned
@@ -695,8 +655,6 @@
695655
}
696656
_request("GET", url, null, cb);
697657
};
698-
=======
699-
>>>>>>> c75337c4b3621f8509ebcddd27bdc4a85b51170a
700658
};
701659

702660
// Gists API

test/test.repo.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,44 @@ test("Repo API", function(t) {
4747

4848
});
4949

50-
test('Repo Returns commit errors correctly', function(t){
50+
var repoTest = Date.now();
51+
52+
test('Create Repo', function(t) {
53+
var timeout = setTimeout(function () { t.fail(); }, 10000);
54+
var github = new Github({
55+
username: test_user.USERNAME,
56+
password: test_user.PASSWORD,
57+
auth: "basic"
58+
});
59+
var user = github.getUser();
60+
61+
user.createRepo({ "name": repoTest }, function (err, res) {
62+
t.error(err);
63+
t.equals(res.name, repoTest.toString(), 'Repo created');
64+
clearTimeout(timeout);
65+
t.end();
66+
});
67+
68+
});
69+
70+
test('delete Repo', function(t) {
71+
var timeout = setTimeout(function () { t.fail(); }, 10000);
72+
var github = new Github({
73+
username: test_user.USERNAME,
74+
password: test_user.PASSWORD,
75+
auth: "basic"
76+
});
77+
var repo = github.getRepo(test_user.USERNAME, repoTest);
78+
repo.deleteRepo(function(err, res) {
79+
t.error(err);
80+
t.equals(res, true, 'Repo Deleted');
81+
clearTimeout(timeout);
82+
t.end();
83+
});
84+
85+
});
86+
87+
test('Repo Returns commit errors correctly', function(t) {
5188
var timeout = setTimeout(function () { t.fail(); }, 10000);
5289
var github = new Github({
5390
username: test_user.USERNAME,

0 commit comments

Comments
 (0)