From 2deb74c29e9ced29caa3aa99730ed16531a02a7d Mon Sep 17 00:00:00 2001 From: Kairat Bakitow Date: Mon, 30 Jan 2017 23:51:09 +0600 Subject: [PATCH 01/55] Fix incorrect path for delete hook API (#418) --- lib/Repository.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Repository.js b/lib/Repository.js index fb200397..d338b261 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -603,7 +603,7 @@ class Repository extends Requestable { * @return {Promise} - the promise for the http request */ deleteHook(id, cb) { - return this._request('DELETE', `${this.__fullname}/hooks/${id}`, null, cb); + return this._request('DELETE', `/repos/${this.__fullname}/hooks/${id}`, null, cb); } /** From 22b889cd48cd281812b020d85f8ea502af69ddfd Mon Sep 17 00:00:00 2001 From: Julien Vanier Date: Fri, 24 Feb 2017 12:29:42 -0500 Subject: [PATCH 02/55] Docs fix for getProject (#428) --- lib/GitHub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GitHub.js b/lib/GitHub.js index 59cb94ff..c5cec4e2 100644 --- a/lib/GitHub.js +++ b/lib/GitHub.js @@ -117,7 +117,7 @@ class GitHub { /** * Create a new Project wrapper * @param {string} id - the id of the project - * @return {Markdown} + * @return {Project} */ getProject(id) { return new Project(id, this.__auth, this.__apiBase); From 1c18ef0eea29bb0aeb1b5dd79034ce3d1f77baf7 Mon Sep 17 00:00:00 2001 From: Andrii Lundiak Date: Fri, 8 Sep 2017 22:29:22 +0200 Subject: [PATCH 03/55] typo fix in GitHub.js --- lib/GitHub.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/GitHub.js b/lib/GitHub.js index c5cec4e2..fddd72ea 100644 --- a/lib/GitHub.js +++ b/lib/GitHub.js @@ -71,7 +71,7 @@ class GitHub { /** * Create a new Repository wrapper - * @param {string} user - the user who owns the respository + * @param {string} user - the user who owns the repository * @param {string} repo - the name of the repository * @return {Repository} */ @@ -81,7 +81,7 @@ class GitHub { /** * Create a new Issue wrapper - * @param {string} user - the user who owns the respository + * @param {string} user - the user who owns the repository * @param {string} repo - the name of the repository * @return {Issue} */ From 24223f7a51ba935f1c86ffd552dac20e8f3e359d Mon Sep 17 00:00:00 2001 From: Miyata Jumpei Date: Wed, 27 Sep 2017 01:15:56 +0900 Subject: [PATCH 04/55] chore: fix broken tests (#474) --- lib/Requestable.js | 2 +- test/organization.spec.js | 6 ++++-- test/team.spec.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Requestable.js b/lib/Requestable.js index bad111ac..44702b94 100644 --- a/lib/Requestable.js +++ b/lib/Requestable.js @@ -256,7 +256,7 @@ class Requestable { results.push(...thisGroup); const nextUrl = getNextPage(response.headers.link); - if (nextUrl && typeof options.page !== 'number') { + if (nextUrl && !(options && typeof options.page !== 'number')) { log(`getting next page: ${nextUrl}`); return this._requestAllPages(nextUrl, options, cb, results); } diff --git a/test/organization.spec.js b/test/organization.spec.js index 26fd3607..710ebbcf 100644 --- a/test/organization.spec.js +++ b/test/organization.spec.js @@ -17,11 +17,13 @@ describe('Organization', function() { password: testUser.PASSWORD, auth: 'basic', }); - return; + createdProject = undefined; }); after(function() { - return github.getProject(createdProject.id).deleteProject(); + if (createdProject) { + return github.getProject(createdProject.id).deleteProject(); + } }); describe('reading', function() { diff --git a/test/team.spec.js b/test/team.spec.js index 8a5ec8be..8f975384 100644 --- a/test/team.spec.js +++ b/test/team.spec.js @@ -159,7 +159,7 @@ describe('Team', function() { // Isolate tests that need a new team per test }); it('should add membership for a given user', function() { - return team.addMembership(testUser.USERNAME) + return team.addMembership(altUser.USERNAME) .then(({data}) => { const {state, role} = data; expect(state === 'active' || state === 'pending').to.be.true(); From 64a9223cc3817b583e387efb47f7e10e9e98dba7 Mon Sep 17 00:00:00 2001 From: Clay Jensen-Reimann Date: Sun, 31 Mar 2019 18:49:32 -0500 Subject: [PATCH 05/55] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 919b5eb3..d6c7c16c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# Maintainers wanted +[Apply within](https://github.com/github-tools/github/issues/539) + # Github.js [![Downloads per month](https://img.shields.io/npm/dm/github-api.svg?maxAge=2592000)][npm-package] From 076229dac843f5519d4b51fcc723cd2705b3e8f8 Mon Sep 17 00:00:00 2001 From: Jared Rewerts Date: Fri, 5 Apr 2019 15:07:59 -0600 Subject: [PATCH 06/55] Fixed null ref test failure. --- test/repository.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repository.spec.js b/test/repository.spec.js index ef5101cf..40d43397 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -169,7 +169,7 @@ describe('Repository', function() { it('should fail when null ref is passed', function(done) { remoteRepo.getSingleCommit(null, assertFailure(done, function(err) { - expect(err.response.status).to.be(404); + expect(err.response.status).to.be(422); done(); })); }); From dcc347289b047ff35d4af9d6f1c330487e9bac18 Mon Sep 17 00:00:00 2001 From: Jared Rewerts Date: Fri, 5 Apr 2019 14:49:55 -0600 Subject: [PATCH 07/55] Updated markdown GFM test. --- test/markdown.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/markdown.spec.js b/test/markdown.spec.js index eef9fe08..d3738d03 100644 --- a/test/markdown.spec.js +++ b/test/markdown.spec.js @@ -37,7 +37,7 @@ describe('Markdown', function() { }; markdown.render(options) .then(function({data: html}) { - expect(html).to.be('

Hello world github/linguist#1 cool, and #1!

'); // eslint-disable-line + expect(html).to.be('

Hello world github/linguist#1 cool, and gollum#1!

'); // eslint-disable-line done(); }).catch(done); }); From cd264468b459117ab7347b9069daf98a580f282f Mon Sep 17 00:00:00 2001 From: Kenshi Kamata Date: Tue, 9 Apr 2019 12:49:09 +0900 Subject: [PATCH 08/55] feature(User): Add List starred gists API (#475) * get list of starred gist api --- lib/User.js | 17 +++++++++++++++++ test/user.spec.js | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/lib/User.js b/lib/User.js index 3f3b4bb6..7e2660d5 100644 --- a/lib/User.js +++ b/lib/User.js @@ -132,6 +132,23 @@ class User extends Requestable { return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb); } + /** + * Gets the list of starred gists for the user + * @see https://developer.github.com/v3/gists/#list-starred-gists + * @param {Object} [options={}] - any options to refine the search + * @param {Requestable.callback} [cb] - will receive the list of gists + * @return {Promise} - the promise for the http request + */ + listStarredGists(options, cb) { + options = options || {}; + if (typeof options === 'function') { + cb = options; + options = {}; + } + options.since = this._dateToISO(options.since); + return this._request('GET', '/gists/starred', options, cb); + } + /** * List email addresses for a user * @see https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user diff --git a/test/user.spec.js b/test/user.spec.js index 2296781c..b2ecc66e 100644 --- a/test/user.spec.js +++ b/test/user.spec.js @@ -61,6 +61,13 @@ describe('User', function() { user.listStarredRepos(assertArray(done)); }); + it('should show user\'s starred gists', function(done) { + const option = { + since: '2015-01-01T00:00:00Z', + }; + user.listStarredGists(option, assertArray(done)); + }); + it('should follow user', function(done) { user.follow('ingalls', assertSuccessful(done)); }); From cda24412632ac334387d27ec507d075b6b200b69 Mon Sep 17 00:00:00 2001 From: Alangi Derick Date: Thu, 17 Aug 2017 13:55:48 +0100 Subject: [PATCH 09/55] Adding styling to text Added styles to some portion of the text to make it more user friendly :). --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d6c7c16c..3be89eb5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Travis](https://img.shields.io/travis/github-tools/github.svg?maxAge=60)][travis-ci] [![Codecov](https://img.shields.io/codecov/c/github/github-tools/github.svg?maxAge=2592000)][codecov] -Github.js provides a minimal higher-level wrapper around Github's API. +`Github.js` provides a minimal higher-level wrapper around Github's API. ## Usage @@ -71,7 +71,7 @@ clayreimann.listStarredRepos(function(err, repos) { should include updated JSDoc. ## Installation -Github.js is available from `npm` or [unpkg][unpkg]. +`Github.js` is available from `npm` or [unpkg][unpkg]. ```shell npm install github-api @@ -86,10 +86,10 @@ npm install github-api ``` ## Compatibility -`Github.js` is tested on Node.js: +`Github.js` is tested on `Node.js`: * 6.x -Note: `Github.js` uses Promise, hence it will not work in Node.js < 4 without polyfill. +Note: `Github.js` uses Promise, hence it will not work in `Node.js` < 4 without polyfill. [codecov]: https://codecov.io/github/github-tools/github?branch=master [docs]: http://github-tools.github.io/github/ From 943ac8a7d36dbac6c0848bee9a5ca64dc229f807 Mon Sep 17 00:00:00 2001 From: Andrii Lundiak Date: Sat, 9 Sep 2017 18:41:17 +0200 Subject: [PATCH 10/55] typo fix in Repository.js --- lib/Repository.js | 2 +- lib/Requestable.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..45ca3f94 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -14,7 +14,7 @@ import debug from 'debug'; const log = debug('github:repository'); /** - * Respository encapsulates the functionality to create, query, and modify files. + * Repository encapsulates the functionality to create, query, and modify files. */ class Repository extends Requestable { /** diff --git a/lib/Requestable.js b/lib/Requestable.js index 44702b94..ab43d9d0 100644 --- a/lib/Requestable.js +++ b/lib/Requestable.js @@ -124,7 +124,7 @@ class Requestable { /** * if a `Date` is passed to this function it will be converted to an ISO string - * @param {*} date - the object to attempt to cooerce into an ISO date string + * @param {*} date - the object to attempt to coerce into an ISO date string * @return {string} - the ISO representation of `date` or whatever was passed in if it was not a date */ _dateToISO(date) { @@ -235,7 +235,7 @@ class Requestable { * @param {string} path - the path to request * @param {Object} options - the query parameters to include * @param {Requestable.callback} [cb] - the function to receive the data. The returned data will always be an array. - * @param {Object[]} results - the partial results. This argument is intended for interal use only. + * @param {Object[]} results - the partial results. This argument is intended for internal use only. * @return {Promise} - a promise which will resolve when all pages have been fetched * @deprecated This will be folded into {@link Requestable#_request} in the 2.0 release. */ From e26c2927a2a4f7abfe152cbd5233be48865435c4 Mon Sep 17 00:00:00 2001 From: Clay Jensen-Reimann Date: Tue, 9 Apr 2019 14:57:40 -0500 Subject: [PATCH 11/55] Update build versions, document in readme --- .travis.yml | 6 +++--- README.md | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26f56aa3..ee525e3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ sudo: false language: node_js node_js: - - '6' - - '5' - - '4' + - '11' + - '10' + - '8' cache: directories: diff --git a/README.md b/README.md index 3be89eb5..bf021040 100644 --- a/README.md +++ b/README.md @@ -86,10 +86,7 @@ npm install github-api ``` ## Compatibility -`Github.js` is tested on `Node.js`: -* 6.x - -Note: `Github.js` uses Promise, hence it will not work in `Node.js` < 4 without polyfill. +`Github.js` is tested on node's LTS and current versions. [codecov]: https://codecov.io/github/github-tools/github?branch=master [docs]: http://github-tools.github.io/github/ From 9fb1f2f6fbb61009800bbf2a1dc19da7d94157b5 Mon Sep 17 00:00:00 2001 From: JongChan Choi Date: Tue, 3 Oct 2017 03:50:54 +0900 Subject: [PATCH 12/55] gist id is string --- lib/GitHub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/GitHub.js b/lib/GitHub.js index fddd72ea..7c3ac24c 100644 --- a/lib/GitHub.js +++ b/lib/GitHub.js @@ -34,7 +34,7 @@ class GitHub { /** * Create a new Gist wrapper - * @param {number} [id] - the id for the gist, leave undefined when creating a new gist + * @param {string} [id] - the id for the gist, leave undefined when creating a new gist * @return {Gist} */ getGist(id) { From 38530fa329d636ff2233065f8048437b1ab4ef51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20P=C3=A9rez?= Date: Sat, 31 Mar 2018 10:09:46 +0200 Subject: [PATCH 13/55] Implementing methods to retrieve list of followers and following users. Github v3 provides the endpoints `followers` and `following` associated to the user entity. This change provides support for them and implements basic unit tests for them. --- lib/User.js | 20 ++++++++++++++++++++ test/user.spec.js | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/lib/User.js b/lib/User.js index 7e2660d5..4848a1c6 100644 --- a/lib/User.js +++ b/lib/User.js @@ -81,6 +81,26 @@ class User extends Requestable { return this._request('GET', this.__getScopedUrl('orgs'), null, cb); } + /** + * List followers of a user + * @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user + * @param {Requestable.callback} [cb] - will receive the list of followers + * @return {Promise} - the promise for the http request + */ + listFollowers(cb) { + return this._request('GET', this.__getScopedUrl('followers'), null, cb); + } + + /** + * List users followed by another user + * @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user + * @param {Requestable.callback} [cb] - will receive the list of who a user is following + * @return {Promise} - the promise for the http request + */ + listFollowing(cb) { + return this._request('GET', this.__getScopedUrl('following'), null, cb); + } + /** * List the user's gists * @see https://developer.github.com/v3/gists/#list-a-users-gists diff --git a/test/user.spec.js b/test/user.spec.js index b2ecc66e..9b033ef1 100644 --- a/test/user.spec.js +++ b/test/user.spec.js @@ -34,6 +34,14 @@ describe('User', function() { user.listOrgs(assertArray(done)); }); + it('should get user followers', function(done) { + user.listFollowers(assertArray(done)); + }); + + it('should get user following list', function(done) { + user.listFollowing(assertArray(done)); + }); + it('should get user gists', function(done) { user.listGists(assertArray(done)); }); From 90fb78b2fb4b4e8e607d24a3dacc983caed2437e Mon Sep 17 00:00:00 2001 From: Jared Rewerts Date: Tue, 9 Apr 2019 20:51:40 -0600 Subject: [PATCH 14/55] feature: Add commit author (#547) --- lib/Repository.js | 12 +++++++++++- test/repository.spec.js | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/Repository.js b/lib/Repository.js index 45ca3f94..f59cf0d0 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -334,16 +334,26 @@ class Repository extends Requestable { * @param {string} parent - the SHA of the parent commit * @param {string} tree - the SHA of the tree for this commit * @param {string} message - the commit message + * @param {Object} [options] - commit options + * @param {Object} [options.author] - the author of the commit + * @param {Object} [options.commiter] - the committer * @param {Requestable.callback} cb - will receive the commit that is created * @return {Promise} - the promise for the http request */ - commit(parent, tree, message, cb) { + commit(parent, tree, message, options, cb) { + if (typeof options === 'function') { + cb = options; + options = {}; + } + let data = { message, tree, parents: [parent], }; + data = Object.assign({}, options, data); + return this._request('POST', `/repos/${this.__fullname}/git/commits`, data, cb) .then((response) => { this.__currentTree.sha = response.data.sha; // Update latest commit diff --git a/test/repository.spec.js b/test/repository.spec.js index 40d43397..62bb3ba6 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -600,6 +600,45 @@ describe('Repository', function() { })); }); + it('should succeed on proper commit', function(done) { + let parentSHA = ''; + let treeSHA = ''; + remoteRepo.getRef('heads/master').then((ref) => { + parentSHA = ref.data.object.sha; + return remoteRepo.getCommit(parentSHA); + }).then((commit) => { + treeSHA = commit.data.tree.sha; + return remoteRepo.commit(parentSHA, treeSHA, 'is this thing on?'); + }).then((commit) => { + expect(commit.data.author).to.have.own('name', 'Mike de Boer'); + expect(commit.data.author).to.have.own('email', 'mike@c9.io'); + done(); + }); + }); + + it('should allow commit to change author', function(done) { + let parentSHA = ''; + let treeSHA = ''; + remoteRepo.getRef('heads/master').then((ref) => { + parentSHA = ref.data.object.sha; + return remoteRepo.getCommit(parentSHA); + }).then((commit) => { + treeSHA = commit.data.tree.sha; + return remoteRepo.commit(parentSHA, treeSHA, 'Who made this commit?', { + author: { + name: 'Jimothy Halpert', + email: 'jim@dundermifflin.com', + }, + }); + }).then((commit) => { + expect(commit.data.author).to.have.own('name', 'Jimothy Halpert'); + expect(commit.data.author).to.have.own('email', 'jim@dundermifflin.com'); + done(); + }).catch((err) => { + throw err; + }); + }); + it('should create a release', function(done) { const releaseDef = { name: releaseName, From bf6b42a040a2f0461e5ab855496a5a457d3f0c71 Mon Sep 17 00:00:00 2001 From: CodyGramlich Date: Wed, 10 Apr 2019 22:24:26 -0600 Subject: [PATCH 15/55] Use username arg for follow and unfollow requests. --- lib/User.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/User.js b/lib/User.js index 3f3b4bb6..3b5cb653 100644 --- a/lib/User.js +++ b/lib/User.js @@ -150,7 +150,7 @@ class User extends Requestable { * @return {Promise} - the promise for the http request */ follow(username, cb) { - return this._request('PUT', `/user/following/${this.__user}`, null, cb); + return this._request('PUT', `/user/following/${username}`, null, cb); } /** @@ -161,7 +161,7 @@ class User extends Requestable { * @return {Promise} - the promise for the http request */ unfollow(username, cb) { - return this._request('DELETE', `/user/following/${this.__user}`, null, cb); + return this._request('DELETE', `/user/following/${username}`, null, cb); } /** From 5a5d87e94185baced8a8b6268717c5dfac8bcf8e Mon Sep 17 00:00:00 2001 From: Clay Jensen-Reimann Date: Tue, 16 Apr 2019 20:18:34 -0500 Subject: [PATCH 16/55] 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ea2eb9a..4f28fdb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-api", - "version": "3.1.0", + "version": "3.2.0", "license": "BSD-3-Clause-Clear", "description": "A higher-level wrapper around the Github API.", "main": "dist/components/GitHub.js", From ee64cd1e352ad0354ea6ce0e8abf676a7f57204d Mon Sep 17 00:00:00 2001 From: Clay Jensen-Reimann Date: Tue, 16 Apr 2019 20:45:52 -0500 Subject: [PATCH 17/55] Updated npm deployment token --- .travis.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee525e3e..6b6bad91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,21 @@ sudo: false language: node_js node_js: - - '11' - - '10' - - '8' - +- '11' +- '10' +- '8' cache: directories: - - node_modules + - node_modules before_install: npm install -g npm@latest before_script: - - npm run lint - # - npm run build # will need this when we do sauce testing of compiled files +- npm run lint script: - - npm run test-coverage - # - npm run test-dist # test the compiled files +- npm run test-coverage after_success: - - npm run codecov +- npm run codecov before_deploy: - - npm run build +- npm run build deploy: provider: npm skip_cleanup: true @@ -26,4 +23,4 @@ deploy: tags: true email: clayreimann@gmail.com api_key: - secure: TZHqJ9Kh2Qf0GAVDjEOQ01Ez6rGMYHKwVLOKTbnb7nSzF7iiGNT4UwzvYawm0T9p1k7X1WOqW3l7OEbIwoKl7/9azT4BBJm7qUMRfB9Zio5cL3rKubJVz7+LEEIW4iBeDWLanhUDgy9BO2JKCt8bfp/U2tltgXtu9Fm/UFPALI8= + secure: WnLh1m02aF7NvFNILCZ8KsjPuDeSddQI87y8dwAixStr2FhQyz8FIKZN2Qj1N1Q9ZJvBETe5HWs1c9yOjTKBkD0d/eU2hlpnB9WXEFRJVDjiUuMnpAMMvuqTZwYg6kXq5N+of95PX58AYiBiV/qwsdUr/MgjEEYLt5UZgRYQRvE= From 09384e3981de3ef40caddff62fcefccf6aa89523 Mon Sep 17 00:00:00 2001 From: Jared Rewerts Date: Tue, 16 Apr 2019 18:54:09 -0700 Subject: [PATCH 18/55] Fix browser markdown (#548) Got the code from PR #505. Fixes #451. --- lib/Markdown.js | 2 +- test/dist.spec/index.html | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Markdown.js b/lib/Markdown.js index edc346cc..ebfbb512 100644 --- a/lib/Markdown.js +++ b/lib/Markdown.js @@ -32,7 +32,7 @@ class Markdown extends Requestable { * @return {Promise} - the promise for the http request */ render(options, cb) { - return this._request('POST', '/markdown', options, cb); + return this._request('POST', '/markdown', options, cb, true); } } diff --git a/test/dist.spec/index.html b/test/dist.spec/index.html index da5a21de..b0a32d7b 100644 --- a/test/dist.spec/index.html +++ b/test/dist.spec/index.html @@ -12,7 +12,7 @@