const GithubRemoteBlamer = ;const blamer = 'MY_GITHUB_API_TOKEN';const organization = 'expressjs';const repository = 'express';const oid = '40e04ec7a6d365a7e083b0fdf7f9d2c7afc036a0'; //GitHub Object ID; can be commit hash or branch name.const path = 'examples/auth/index.js';const lineNumber = 7;blamer;
Requires node version 8 or higher.
$ npm install --save github-remote-blamer
GithubRemoteBlamer's constructor takes two parameters:
- apiToken - Github api token with read access to the repository, users, and organization. This is required.
- options - an object with additional options. Currently
debugis the only supported option. Set to
truefor additional debug statements.
const blamer = myGitHubApiToken debug: true;
GithubRemoteBlamer.blame() requires five parameters:
- organization - the GitHub organization which the respository being blamed belongs to.
- respository - the name of the repostiroy containing the file being blamed
- oid - the github object id for which version of the repository to blame. Can be a commit hash, or the name of a branch. If its the name of a branch, the latest version for that branch will be used.
- path - the path within the repository to the file being blamed
- lines - can be either a single integer representing the line to blame, or an array of integers to blame multiple lines in the same file.
GithubRemoteBlamer.blame() returns a
Promise that resolves to either a single object or an array of objects depending
on whether or not you are blaming multiple lines. If blaming a single line, a single object is returned,. If blaming multiple
lines, the array will have an object for each line, in order of the lines as they appear in the file.
blameInfo = blamer;