node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

name-your-contributors

name-your-contributors

Greenkeeper badge

Build Status

Name your GitHub contributors; get commits, issues, and comments

name-your-contributors gets all of the code reviewers, commenters, issue and PR creators from your organization or repo.

Install

$ npm install --save name-your-contributors

API Limits and setting up a GitHub Token

You also need to get a GitHub application token to access the API. Go here: https://github.com/settings/tokens. Click on "Generate New Token". It needs to have the read:org scope in order to search by organization. Name the token something informative: name-your-contributors is a good name.

Set the token with the variable name $GITHUB_TOKEN before running the script:

export GITHUB_TOKEN=ab34e...

You can also set the var automatically in every session by adding the above line to your .bashrc file in your home directory.

Caveats

GitHub regulates API traffic by a credit system. The limits are quite high; it's permitted to query hundreds of repos per hour using the repoContributors function, but some organisations have many hundreds of repos, and a single call to orgContributors could potentially exhaust your entire hourly quota. The WikiMedia Foundation is a good example of an org with way too many repos for this app to handle.

Unfortunately filtering by contributions before or after a given date has no effect on quota use, since the data still needs to be queried before it can be filtered.

For more details on rate limits, see https://developer.github.com/v4/guides/resource-limitations/.

Usage

From Code

const nyc = require('name-your-contributors')
 
nyc.repoContributors({
    token: process.env.GITHUB_TOKEN,
    user: 'RichardLitt',
    repo: 'name-your-contributors'
    }).then(//do something with the results
    )
})
 
nyc.orgContributors({
    token: process.env.GITHUB_TOKEN,
    orgName: 'ipfs',
    before: '2017-01-01',
    after: '2016-01-01'
    }).then(...)

From the Command Line

$ npm install -g name-your-contributors
 
export GITHUB_TOKEN={your-token}
$ name-your-contributors -u RichardLitt -r name-your-contributors
 
$ name-your-contributors -o ipfs -a 2017-01-01 > ipfs-contrib.json

API

orgContributors({orgName, token, before, after})

token

Type: string

Github auth token

org

Type: string

The organization to traverse. If no organization is provided, the script will find the username and repo for the local git repository and use that.

opts.after

Type: string

The ISO timestamp to get contributors after.

Any string that will be accepted by new Date("...") will work here as expected.

opts.before

Type: string

Get contributors from before this ISO timestamp.

repoContributors({user, repo, token, before, after})

opts.user

Type: string

Github user name to whom the repo belongs.

opts.repo

Type: string

Only traverse the given repository.

License

MIT © Richard Littauer