Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: octokit/rest.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 14f18c20f1aba099462d1cb907f7a41ca5945e9e
Choose a base ref
...
head repository: octokit/rest.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3c4ab020c640c04f52e5d8d2d7bb5835bed540f6
Choose a head ref

Commits on Nov 29, 2017

  1. Copy the full SHA
    f7b9706 View commit details
  2. Copy the full SHA
    2d68733 View commit details
  3. Copy the full SHA
    8d90f3b View commit details
  4. breaking: remove custom Promise option

    BREAKING CHANGE: passing a custom `Promise` option to the constructor is no longer supported
    
    ```js
    const Client = require(./../lib/index)
    const github = new Client({
      Promise: Promise
    })
    ```
    
    All suppertod Node versions (4, 6 and 8) have Promise support built in now. So migrating should be as simple as removing the `Promise` option altogether.
    gr2m committed Nov 29, 2017
    Copy the full SHA
    68cf60e View commit details
  5. breaking: remove "netrc" authentication type (#640)

    BREAKING CHANGE: Authentication with `"netrc"` is no longer supported:
    
    ```js
    github.authenticate({
      type: "netrc"
    })
    ```
    
    Instead, use the [netrc](https://www.npmjs.com/package/netrc) package directly and pass username/password to `"basic"` authentication
    
    ```js
    const netrc = require('netrc')
    const myNetrc = netrc()
    
    github.authenticate({
      type: 'basic',
      username: myNetrc['api.github.com'].login,
      password: myNetrc['api.github.com'].password
    })
    ```
    copperwall authored and gr2m committed Nov 29, 2017
    Copy the full SHA
    ad4f149 View commit details
  6. Copy the full SHA
    70b0611 View commit details
  7. Copy the full SHA
    5239442 View commit details
  8. test: follow redirects

    gr2m committed Nov 29, 2017
    Copy the full SHA
    0893c81 View commit details
  9. feat: always follow redirects

    BREAKING CHANGE: the `followRedirects` option has been removed. Previous problems with non-GET redirects should be handled correctly now, the method is always forwarded as all redirects remain within the same host
    gr2m committed Nov 29, 2017
    Copy the full SHA
    61e7a81 View commit details
  10. chore(package): url-template

    gr2m committed Nov 29, 2017
    Copy the full SHA
    1fba0f0 View commit details
  11. Copy the full SHA
    8423f04 View commit details
  12. fix: github.repos.uploadAsset() options

    BREAKING CHANGE: The current implementation has the upload URL hard coded, while the specification says that it has to be received from the Release API endpoint:
    https://developer.github.com/v3/repos/releases/#upload-a-release-asset
    
    The new implementation also requires `contentType` as well as `contentLength`. The latter is not documented, but is required. The `filePath` option has been replaced with a `file` option which can be either a read stream, a buffer or a string.
    
    Altogether, uploading an asset before worked like this:
    
    ```js
    github.repos.getReleaseByTag({
      owner: "octokit-fixture-org",
      repo: "release-assets",
      tag: "v1.0.0"
    })
    
    .then(result => {
      return github.repos.uploadAsset({
        owner: "octokit-fixture-org",
        repo: "release-assets",
        id: result.data.id,
        filePath: pathResolve(__dirname, "test-upload.txt"),
        name: "test-upload.txt",
        label: "test"
      })
    })
    ```
    
    Now it looks like this
    
    ```js
    github.repos.getReleaseByTag({
      owner: "octokit-fixture-org",
      repo: "release-assets  repo: "release-assets  repo: "release-assets  repo: "release-assets  repo: "release-assets  repo: "release-assets  repo: "release-assets  repo: "release-assett/  repo: "release-assets  repo: "release-assets  repo: "releas   label: "test"
      })
    })
    ```
    
    If you prefer a higher-level release asset upload library, have a look at https://github.com/gr2m/octokit-release-asset-upload
    gr2m committed Nov 29, 2017
    Copy the full SHA
    07d5e36 View commit details
  13. Copy the full SHA
    2430c6a View commit details
  14. Copy the full SHA
    9562736 View commit details
  15. Copy the full SHA
    f88a044 View commit details
  16. Copy the full SHA
    2a08766 View commit details
  17. breaking: debug option removed

    BREAKING CHANGE: The `debug` option for the GitHub Client constructor
    has been removed. Set `DEBUG=node-github:*` environment variable instead
    gr2m committed Nov 29, 2017
    Copy the full SHA
    c2c9f8a View commit details
  18. chore(package): debug, nock

    gr2m committed Nov 29, 2017
    Copy the full SHA
    175ee19 View commit details
  19. test: invalid argument

    gr2m committed Nov 29, 2017
    Copy the full SHA
    50ab622 View commit details
  20. test: constructor

    gr2m committed Nov 29, 2017
    Copy the full SHA
    101d74c View commit details
  21. Copy the full SHA
    d57f369 View commit details
  22. Copy the full SHA
    535f150 View commit details
  23. Copy the full SHA
    a469313 View commit details
  24. Copy the full SHA
    5b88470 View commit details
  25. Copy the full SHA
    5cd8b80 View commit details
  26. test: add test for github.get{scopeName}Api()

    We can porbably remove it. It’s 6+ years old and not documented
    gr2m committed Nov 29, 2017
    Copy the full SHA
    04703f7 View commit details
  27. chore: remove unneded code

    We are in full control of the recursive loops, we don’t need that check
    gr2m committed Nov 29, 2017
    Copy the full SHA
    8e3823b View commit details
  28. chore(package): simple-mock

    gr2m committed Nov 29, 2017
    Copy the full SHA
    9a30714 View commit details
  29. test: callback

    gr2m committed Nov 29, 2017
    Copy the full SHA
    9b5d1c4 View commit details
  30. test: deprecations

    gr2m committed Nov 29, 2017
    Copy the full SHA
    cb03bb5 View commit details
  31. test: setup routes

    gr2m committed Nov 29, 2017
    Copy the full SHA
    b8ad015 View commit details
  32. chore: remove unused code

    gr2m committed Nov 29, 2017
    Copy the full SHA
    21db66f View commit details
  33. Copy the full SHA
    1299382 View commit details
  34. test: pagination

    gr2m committed Nov 29, 2017
    Copy the full SHA
    cfd77d2 View commit details
  35. chore: remove unused code

    There is not a single route definition without a params property
    gr2m committed Nov 29, 2017
    Copy the full SHA
    611f4c7 View commit details
  36. chore: remove unneeded code

    gr2m committed Nov 29, 2017
    Copy the full SHA
    085870f View commit details
  37. test: authentication

    gr2m committed Nov 29, 2017
    Copy the full SHA
    5a7fd70 View commit details
  38. Copy the full SHA
    45bd678 View commit details
  39. Copy the full SHA
    3639a98 View commit details
  40. Copy the full SHA
    f868bfa View commit details
  41. test: cover deprecated options

    gr2m committed Nov 29, 2017
    Copy the full SHA
    823f605 View commit details
  42. breaking: remove support to pass link header contents to pagination…

    … methods
    
    BREAKING CHANGE: Before a link header could be passed directly to pagination methods like `github.hasPreviousPage(linkHeaderValue)`. This was never documented and is not being used internally, so we decided to remove the functionality to simplify the code
    gr2m committed Nov 29, 2017
    Copy the full SHA
    e4a24c6 View commit details
  43. chore: remove unneeded check if headers are set

    At least the accept header is always set
    gr2m committed Nov 29, 2017
    Copy the full SHA
    e23579e View commit details
  44. chore: remove unneeded port fallback

    protocol is set in definitions.json
    gr2m committed Nov 29, 2017
    Copy the full SHA
    77b64e0 View commit details
  45. Copy the full SHA
    596e7ca View commit details
  46. chore: remove code for undocumented/unusable url option

    I tried to write a test for this just to make sure that somebody is not using it, but couldn’t get it to work so I assume this is some legacy code that has been forgotten to be removed
    gr2m committed Nov 29, 2017
    Copy the full SHA
    2e5c03e View commit details
  47. Copy the full SHA
    54ebd40 View commit details
  48. chore: remove unused code for format != json/raw

    `format` is set from `requestFormat` in routes.json and definitions.json: there are only the values "raw" or the default "json"
    gr2m committed Nov 29, 2017
    Copy the full SHA
    2ffd459 View commit details
  49. Copy the full SHA
    b4482e6 View commit details
  50. chore: remove unused code

    This is code from the ajax.org origin. There is only one parameter of type Object which is "file", and file is not a query parameter, so this code is never reached
    gr2m committed Nov 29, 2017
    Copy the full SHA
    58178ca View commit details
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ node_modules
lib/index.d.ts
lib/index.js.flow

# API DOCs are generated before publish
doc/

logs
*.log
npm-debug.log*
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- "9"
- "8"
- "6"
- "4"
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -44,4 +44,7 @@ Only one version number is bumped at a time, the highest version change trumps t
Besides publishing a new version to npm, semantic-release also creates a git tag and release
on GitHub, generates changelogs from the commit messages and puts them into the release notes.

Before the publish it runs the `npm run build` script which generates type definitions for Flow & Typescript based on the [templates](scripts/templates/).
The script also generates the API docs. After the publish, the API docs are automatically pushed to the `gh-pages` branch which updates the documentation at [octokit.github.io/node-github](http://octokit.github.io/node-github/).

If the pull request looks good but does not follow the commit conventions, use the "Squash & merge" button.
27 changes: 5 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,13 +32,13 @@ GitHub API: [developer.github.com/v3](https://developer.github.com/v3/)

Get all followers for user "defunkt":

<!-- HEADS UP: when changing the options for the constructor, make sure to also
update the type definition templates in scripts/templates/* -->
```js
var GitHubApi = require('github')

var github = new GitHubApi({
// optional
debug: true,
Promise: require('bluebird'),
timeout: 5000,
host: 'github.my-GHE-enabled-company.com', // should be api.github.com for GitHub
pathPrefix: '/api/v3', // for some GHEs; none for GitHub
@@ -52,7 +52,6 @@ var github = new GitHubApi({
'user-agent': 'something custom'
},
requestMedia: 'application/vnd.github.something-custom',
followRedirects: false, // default: true; there's currently an issue with non-get redirects, so allow disabling follow-redirects
rejectUnauthorized: false, // default: true
family: 6
})
@@ -129,11 +128,6 @@ github.authenticate({
type: 'integration',
token: 'jwt'
})

// ~/.netrc
github.authenticate({
type: 'netrc'
})
```

Note: `authenticate` is synchronous because it only stores the
@@ -161,9 +155,9 @@ github.authorization.create({
})
```

## Promises
## DEBUG

See example [here](https://github.com/octokit/node-github/blob/master/examples/testPromiseGetNextPage.js).
Set `DEBUG=node-github:*` for additioanl debug logs.

## Tests

@@ -212,17 +206,6 @@ For updates on endpoints under preview, see https://developer.github.com/changes
| Timeline | application/vnd.github.mockingbird-preview |
| Topics | application/vnd.github.mercy-preview+json |

## Dev notes

To update the apidoc for github pages:

```bash
$ npm install apidoc -g
$ apidoc -i doc/ -o apidoc/
```

Just a reminder, since an ad-hoc filter was added to the apidoc, don't overwrite index.html, main.js.

## LICENSE

MIT license. See the LICENSE file for details.
[MIT](LICENSE)
17 changes: 17 additions & 0 deletions examples/testPromise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

var Client = require('./../lib/index')

var github = new Client({
debug: false
})

github.orgs.getAll({
page: 5,
per_page: 100
}).then(function (res) {
console.log(res)
return github.users.getById({ id: '429706' })
}).then(function (res) {
console.log(res)
})
21 changes: 21 additions & 0 deletions lib/definitions.json
Original file line number Diff line number Diff line change
@@ -457,6 +457,27 @@
"validation": "",
"invalidmsg": "",
"description": "Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise."
},
"url": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Dynamic URL for release asset uploads returned by the release’s API response."
},
"contentType": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "The content type of a release asset upload."
},
"contentLength": {
"type": "Number",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Size of release asset upload in bytes."
}
},
"acceptTree": {
3 changes: 1 addition & 2 deletions lib/error.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ var Util = require('util')

exports.HttpError = function (message, code, headers) {
Error.call(this, message)
// Error.captureStackTrace(this, arguments.callee);
this.message = message
this.code = code
this.status = statusCodes[code]
@@ -97,7 +96,7 @@ for (var status in statusCodes) {
var error = (function (defaultMsg, status) {
return function (msg) {
this.defaultMessage = defaultMsg
exports.HttpError.call(this, msg || status + ': ' + defaultMsg, status)
exports.HttpError.call(this, msg, status)

if (status >= 500) { Error.captureStackTrace(this, arguments.callee) } // eslint-disable-line
}
Loading