From f0c084e57c5fefae1218f461effc18a259ae21db Mon Sep 17 00:00:00 2001 From: marcosomma Date: Wed, 24 Feb 2016 12:29:36 +0100 Subject: [PATCH 01/12] added createOrgRepo for create organization repos --- README.md | 6 ++++++ src/github.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 045a66bf..7546a428 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,12 @@ Create a new repo for the authenticated user ```js user.createRepo({"name": "test"}, function(err, res) {}); ``` + +Create a new repo in specific organization for the authenticated user + +```js +user.createOrgRepo(orgname,{"name": "test"}, function(err, res) {}); +``` Repo description, homepage, private/public can also be set. For a full list of options see the docs [here](https://developer.github.com/v3/repos/#create) diff --git a/src/github.js b/src/github.js index cb6546a5..7c0a989f 100644 --- a/src/github.js +++ b/src/github.js @@ -315,6 +315,12 @@ this.createRepo = function (options, cb) { _request('POST', '/user/repos', options, cb); }; + + // Create an Organization repo + // ------- + this.createOrgRepo = function (orgname, options, cb) { + _request('POST', '/orgs/' + orgname + '/repos', options, cb); + }; }; // Repository API From 48fa676cc751716afac7040867ca5ad467484671 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 20:20:37 +0100 Subject: [PATCH 02/12] implemented test --- src/github.js | 10 ++++++++-- test/test.organization.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/test.organization.js diff --git a/src/github.js b/src/github.js index 7c0a989f..701c6255 100644 --- a/src/github.js +++ b/src/github.js @@ -315,11 +315,13 @@ this.createRepo = function (options, cb) { _request('POST', '/user/repos', options, cb); }; + }; + Github.Organization = function () { // Create an Organization repo // ------- - this.createOrgRepo = function (orgname, options, cb) { - _request('POST', '/orgs/' + orgname + '/repos', options, cb); + this.createRepo = function (options, cb) { + _request('POST', '/orgs/' + options.orgname + '/repos', options, cb); }; }; @@ -1108,6 +1110,10 @@ return new Github.User(); }; + Github.getOrganization = function () { + return new Github.Organization(); + }; + Github.getGist = function (id) { return new Github.Gist({ id: id diff --git a/test/test.organization.js b/test/test.organization.js new file mode 100644 index 00000000..06bda48a --- /dev/null +++ b/test/test.organization.js @@ -0,0 +1,38 @@ +'use strict'; + +var Github = require('../src/github.js'); +var testUser = require('./user.json'); +var github, organization; + +describe('Github.Organization', function() { + before(function() { + github = new Github({ + username: testUser.USERNAME, + password: testUser.PASSWORD, + auth: 'basic' + }); + organization = github.getOrganization(); + }); + + it('should create an public organisation repo', function(done) { + var repoTest = Math.floor(Math.random() * (100000 - 0)) + 0; + var options ={ + "orgname": "openaddresses", + "name": repoTest, + "description": "test create repo", + "homepage": "https://github.com/", + "private": false, + "has_issues": true, + "has_wiki": true, + "has_downloads": true + }; + organization.createRepo(options, function(err, repos, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + res.name.should.equal(repoTest.toString()); + + done(); + }); + }); + +}); From 2d654773342ec052bd8a38efb8e0ed96c03c7ef7 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 21:26:48 +0100 Subject: [PATCH 03/12] added ORGANIZATION for test user --- test/user.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/user.json b/test/user.json index 5fdc8e86..33479bef 100644 --- a/test/user.json +++ b/test/user.json @@ -1,5 +1,6 @@ { "USERNAME": "mikedeboertest", "PASSWORD": "test1324", - "REPO": "github" -} \ No newline at end of file + "REPO": "github", + "ORGANIZATION": "github-api-tests" +} From b7ae3d56262c477c0d2cb9adaba1861c13e659bc Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 21:27:30 +0100 Subject: [PATCH 04/12] fix test organization create repos --- test/test.organization.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test.organization.js b/test/test.organization.js index 06bda48a..d173d69b 100644 --- a/test/test.organization.js +++ b/test/test.organization.js @@ -17,7 +17,7 @@ describe('Github.Organization', function() { it('should create an public organisation repo', function(done) { var repoTest = Math.floor(Math.random() * (100000 - 0)) + 0; var options ={ - "orgname": "openaddresses", + "orgname": testUser.ORGANIZATION, "name": repoTest, "description": "test create repo", "homepage": "https://github.com/", @@ -26,10 +26,11 @@ describe('Github.Organization', function() { "has_wiki": true, "has_downloads": true }; - organization.createRepo(options, function(err, repos, xhr) { + organization.createRepo(options, function(err, res, xhr) { should.not.exist(err); xhr.should.be.instanceof(XMLHttpRequest); res.name.should.equal(repoTest.toString()); + res.full_name.should.equal(testUser.ORGANIZATION+"/"+repoTest.toString()); done(); }); From d9cdc80de92417e86ea549aa10ce5c61d6e04a88 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 22:06:48 +0100 Subject: [PATCH 05/12] implemented new 'Organization API' section in the README.md file --- README.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7546a428..fcae4b2a 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,12 @@ bower install github-api [![Sauce Test Status](https://saucelabs.com/browser-matrix/githubjs.svg)](https://saucelabs.com/u/githubjs) -**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying +**Note**: Starting from version 0.10.8, Github.js supports **Internet Explorer 9**. However, the underlying methodology used under the hood to perform CORS requests (the `XDomainRequest` object), [has limitations](http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx). -In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at +In particular, requests must be targeted to the same scheme as the hosting page. This means that if a page is at http://example.com, your target URL must also begin with HTTP. Similarly, if your page is at https://example.com, then -your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), +your target URL must also begin with HTTPS. For this reason, if your requests are sent to the GitHub API (the default), which are served via HTTPS, your page must use HTTPS too. ## GitHub Tools @@ -321,11 +321,6 @@ Create a new repo for the authenticated user user.createRepo({"name": "test"}, function(err, res) {}); ``` -Create a new repo in specific organization for the authenticated user - -```js -user.createOrgRepo(orgname,{"name": "test"}, function(err, res) {}); -``` Repo description, homepage, private/public can also be set. For a full list of options see the docs [here](https://developer.github.com/v3/repos/#create) @@ -342,6 +337,20 @@ List all gists of a particular user. If username is ommitted gists of the curren user.userGists(username, function(err, gists) {}); ``` +## Organization API + + +```js +var organization = github.getOrganization(); +``` + + +Create a new organization repo for the authenticated user + +```js +organization.createRepo(orgname,{"name": "test"}, function(err, res) {}); +``` + ## Gist API ```js From 5091f91fd667acfb397413a4a8ea5dedf037daf7 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 22:08:38 +0100 Subject: [PATCH 06/12] implemented new 'Organization API' section in the README.md file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fcae4b2a..a7f76a3a 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,7 @@ var organization = github.getOrganization(); Create a new organization repo for the authenticated user ```js -organization.createRepo(orgname,{"name": "test"}, function(err, res) {}); +organization.createRepo({"orgname":"github-api-tests","name": "test"}, function(err, res) {}); ``` ## Gist API From bb18f89cc0bf68ea8d26e0f6e3150ed2405d66ec Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 22:37:16 +0100 Subject: [PATCH 07/12] refactoring getOrganization() to getOrg() --- README.md | 28 ++++++++++++++-------------- src/github.js | 2 +- test/test.organization.js | 39 --------------------------------------- 3 files changed, 15 insertions(+), 54 deletions(-) delete mode 100644 test/test.organization.js diff --git a/README.md b/README.md index a7f76a3a..7c8188be 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,20 @@ Unstar a repository. repo.unstar(owner, repository, function(err) {}); ``` +## Organization API + + +```js +var organization = github.getOrg(); +``` + + +Create a new organization repo for the authenticated user + +```js +organization.createRepo({"orgname":"github-api-tests","name": "test"}, function(err, res) {}); +``` + ## User API @@ -337,20 +351,6 @@ List all gists of a particular user. If username is ommitted gists of the curren user.userGists(username, function(err, gists) {}); ``` -## Organization API - - -```js -var organization = github.getOrganization(); -``` - - -Create a new organization repo for the authenticated user - -```js -organization.createRepo({"orgname":"github-api-tests","name": "test"}, function(err, res) {}); -``` - ## Gist API ```js diff --git a/src/github.js b/src/github.js index 701c6255..9bee922a 100644 --- a/src/github.js +++ b/src/github.js @@ -1110,7 +1110,7 @@ return new Github.User(); }; - Github.getOrganization = function () { + Github.getOrg = function () { return new Github.Organization(); }; diff --git a/test/test.organization.js b/test/test.organization.js deleted file mode 100644 index d173d69b..00000000 --- a/test/test.organization.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var Github = require('../src/github.js'); -var testUser = require('./user.json'); -var github, organization; - -describe('Github.Organization', function() { - before(function() { - github = new Github({ - username: testUser.USERNAME, - password: testUser.PASSWORD, - auth: 'basic' - }); - organization = github.getOrganization(); - }); - - it('should create an public organisation repo', function(done) { - var repoTest = Math.floor(Math.random() * (100000 - 0)) + 0; - var options ={ - "orgname": testUser.ORGANIZATION, - "name": repoTest, - "description": "test create repo", - "homepage": "https://github.com/", - "private": false, - "has_issues": true, - "has_wiki": true, - "has_downloads": true - }; - organization.createRepo(options, function(err, res, xhr) { - should.not.exist(err); - xhr.should.be.instanceof(XMLHttpRequest); - res.name.should.equal(repoTest.toString()); - res.full_name.should.equal(testUser.ORGANIZATION+"/"+repoTest.toString()); - - done(); - }); - }); - -}); From 95433dec0e825e73661c3a1377a91080a17e10f7 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 22:40:14 +0100 Subject: [PATCH 08/12] added org tests & fix typos in tests and README --- README.md | 3 +-- test/test.org.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/test.org.js diff --git a/README.md b/README.md index 7c8188be..c074ad1b 100644 --- a/README.md +++ b/README.md @@ -271,8 +271,7 @@ repo.unstar(owner, repository, function(err) {}); var organization = github.getOrg(); ``` - -Create a new organization repo for the authenticated user +Create a new organization repository for the authenticated user ```js organization.createRepo({"orgname":"github-api-tests","name": "test"}, function(err, res) {}); diff --git a/test/test.org.js b/test/test.org.js new file mode 100644 index 00000000..c8c463e4 --- /dev/null +++ b/test/test.org.js @@ -0,0 +1,39 @@ +'use strict'; + +var Github = require('../src/github.js'); +var testUser = require('./user.json'); +var github, organization; + +describe('Github.Organization', function() { + before(function() { + github = new Github({ + username: testUser.USERNAME, + password: testUser.PASSWORD, + auth: 'basic' + }); + organization = github.getOrg(); + }); + + it('should create an organisation repo', function(done) { + var repoTest = Math.floor(Math.random() * (100000 - 0)) + 0; + var options ={ + "orgname": testUser.ORGANIZATION, + "name": repoTest, + "description": "test create organization repo", + "homepage": "https://github.com/", + "private": false, + "has_issues": true, + "has_wiki": true, + "has_downloads": true + }; + organization.createRepo(options, function(err, res, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + res.name.should.equal(repoTest.toString()); + res.full_name.should.equal(testUser.ORGANIZATION+"/"+repoTest.toString()); + + done(); + }); + }); + +}); From bbe5f605089a3c4180990e10294ef0ff18ef34cb Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sun, 28 Feb 2016 22:48:55 +0100 Subject: [PATCH 09/12] added list of options in the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c074ad1b..25f99375 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ Create a new organization repository for the authenticated user ```js organization.createRepo({"orgname":"github-api-tests","name": "test"}, function(err, res) {}); ``` +Repo description, homepage, private/public can also be set. For a full list of options see the docs [here](https://developer.github.com/v3/repos/#create) ## User API @@ -333,7 +334,6 @@ Create a new repo for the authenticated user ```js user.createRepo({"name": "test"}, function(err, res) {}); ``` - Repo description, homepage, private/public can also be set. For a full list of options see the docs [here](https://developer.github.com/v3/repos/#create) From e278c5a076e77f1882bf7df03fcf4ecff639d4e6 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sat, 12 Mar 2016 13:51:19 +0100 Subject: [PATCH 10/12] fix npm run lint issue && removed quote from object && replaced double quete with single quote for Strings --- test/test.org.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/test.org.js b/test/test.org.js index c8c463e4..f80de42c 100644 --- a/test/test.org.js +++ b/test/test.org.js @@ -16,24 +16,24 @@ describe('Github.Organization', function() { it('should create an organisation repo', function(done) { var repoTest = Math.floor(Math.random() * (100000 - 0)) + 0; - var options ={ - "orgname": testUser.ORGANIZATION, - "name": repoTest, - "description": "test create organization repo", - "homepage": "https://github.com/", - "private": false, - "has_issues": true, - "has_wiki": true, - "has_downloads": true + var options = { + orgname: testUser.ORGANIZATION, + name: repoTest, + description: 'test create organization repo', + homepage: 'https://github.com/', + private: false, + has_issues: true, + has_wiki: true, + has_downloads: true }; + organization.createRepo(options, function(err, res, xhr) { should.not.exist(err); xhr.should.be.instanceof(XMLHttpRequest); res.name.should.equal(repoTest.toString()); - res.full_name.should.equal(testUser.ORGANIZATION+"/"+repoTest.toString()); + res.full_name.should.equal(testUser.ORGANIZATION + '/' + repoTest.toString()); done(); }); }); - }); From 480244f6b5c09318f43a481ed3cfd7c7e3f67568 Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sat, 12 Mar 2016 14:13:46 +0100 Subject: [PATCH 11/12] fix travis test --- .travis.yml | 2 ++ test/test.repo.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 88181684..fa7ecb67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,8 @@ cache: before_install: - npm i -g npm@^3.3.0 + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" script: - gulp lint diff --git a/test/test.repo.js b/test/test.repo.js index bb405cdc..d65759bd 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -33,6 +33,7 @@ if (typeof window === 'undefined') { // We're in NodeJS // jscs:disable imageB64 = 'iVBORw0KGgoAAAANSUhEUgAAACsAAAAmCAAAAAB4qD3CAAABgElEQVQ4y9XUsUocURQGYN/pAyMWBhGtrEIMiFiooGuVIoYsSBAsRSQvYGFWC4uFhUBYsilXLERQsDA20YAguIbo5PQp3F3inVFTheSvZoavGO79z+mJP0/Pv2nPtlfLpfLq9tljNquO62S8mj1kmy/8nrHm/Xaz1930bt5n1+SzVmyrilItsod9ON0td1V59xR9hwV2HsMRsbfROLo4amzsRcQw5vO2CZPJEU5CM2cXYTCxg7CY2mwIVhK7AkNZYg9g4CqxVwNwkNg6zOTKMQP1xFZgKWeXoJLYdSjl7BysJ7YBIzk7Ap8TewLOE3oOTtIz6y/64bfQn55ZTIAPd2gNTOTurcbzp7z50v1y/Pq2Q7Wczca8vFjG6LvbMo92hiPL96xO+eYVPkVExMdONetFXZ+l+eP9cuV7RER8a9PZwrloTXv2tfv285ZOt4rnrTXlydxCu9sZmGrdN8eXC3ATERHXsHD5wC7ZL3HdsaX9R3bUzlb7YWvn/9ipf93+An8cHsx3W3WHAAAAAElFTkSuQmCC'; imageBlob = new Blob(); + // jscs:enable } } @@ -207,7 +208,9 @@ describe('Github.Repository', function() { xhr.should.be.instanceof(XMLHttpRequest); statuses.length.should.equal(6); statuses.every(function(status) { - return status.url === 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; + var exp = 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; + + return status.url === exp; }).should.equal(true); done(); From 0ab94fa50692e97ad600638d095f9ee1ed07137e Mon Sep 17 00:00:00 2001 From: marcosomma Date: Sat, 12 Mar 2016 14:38:44 +0100 Subject: [PATCH 12/12] reverted last commit --- .travis.yml | 2 -- test/test.repo.js | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa7ecb67..88181684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,6 @@ cache: before_install: - npm i -g npm@^3.3.0 - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" script: - gulp lint diff --git a/test/test.repo.js b/test/test.repo.js index d65759bd..bb405cdc 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -33,7 +33,6 @@ if (typeof window === 'undefined') { // We're in NodeJS // jscs:disable imageB64 = 'iVBORw0KGgoAAAANSUhEUgAAACsAAAAmCAAAAAB4qD3CAAABgElEQVQ4y9XUsUocURQGYN/pAyMWBhGtrEIMiFiooGuVIoYsSBAsRSQvYGFWC4uFhUBYsilXLERQsDA20YAguIbo5PQp3F3inVFTheSvZoavGO79z+mJP0/Pv2nPtlfLpfLq9tljNquO62S8mj1kmy/8nrHm/Xaz1930bt5n1+SzVmyrilItsod9ON0td1V59xR9hwV2HsMRsbfROLo4amzsRcQw5vO2CZPJEU5CM2cXYTCxg7CY2mwIVhK7AkNZYg9g4CqxVwNwkNg6zOTKMQP1xFZgKWeXoJLYdSjl7BysJ7YBIzk7Ap8TewLOE3oOTtIz6y/64bfQn55ZTIAPd2gNTOTurcbzp7z50v1y/Pq2Q7Wczca8vFjG6LvbMo92hiPL96xO+eYVPkVExMdONetFXZ+l+eP9cuV7RER8a9PZwrloTXv2tfv285ZOt4rnrTXlydxCu9sZmGrdN8eXC3ATERHXsHD5wC7ZL3HdsaX9R3bUzlb7YWvn/9ipf93+An8cHsx3W3WHAAAAAElFTkSuQmCC'; imageBlob = new Blob(); - // jscs:enable } } @@ -208,9 +207,7 @@ describe('Github.Repository', function() { xhr.should.be.instanceof(XMLHttpRequest); statuses.length.should.equal(6); statuses.every(function(status) { - var exp = 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; - - return status.url === exp; + return status.url === 'https://api.github.com/repos/michael/github/statuses/20fcff9129005d14cc97b9d59b8a3d37f4fb633b'; }).should.equal(true); done(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy