-
Notifications
You must be signed in to change notification settings - Fork 10
Change passport-github to passport-github2 and @octokit/rest to v18 #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4947852
d4f3e97
5dca5e7
59a69c4
906349c
5ffc6a3
fbc7679
4f4208c
4ba49d1
d193d5f
3edc303
3c37e63
ac6dc90
8d62ad6
3f17d8c
ec6d5c8
e9dc37e
9767fcd
e1a1dc9
4f099cb
ae56cb1
46b1025
701adfc
bf12a09
b69f41b
35e5132
3394d44
92d5118
96ff0af
0a2f0d3
97b09cc
381b53c
0476e3b
ba47d4c
f74bae4
7a65e0c
aa9d0ff
21c469a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ node_modules | |
| /views/standard/css | ||
| pulldasher.pid | ||
| dist | ||
| /.env.db | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| var GithubApi = require('@octokit/rest'), | ||
| var { Octokit } = require('@octokit/rest'), | ||
| { throttling } = require("@octokit/plugin-throttling"), | ||
| MyOctokit = Octokit.plugin(throttling), | ||
| config = require('./config-loader'), | ||
| Promise = require('bluebird'), | ||
| _ = require('underscore'), | ||
| github = new GithubApi({ | ||
| version: '3.0.0' | ||
| }), | ||
| debug = require('./debug')('pulldasher:github'), | ||
| utils = require('./utils'), | ||
| Pull = require('../models/pull'), | ||
|
|
@@ -14,25 +13,45 @@ var GithubApi = require('@octokit/rest'), | |
| Label = require('../models/label'), | ||
| Status = require('../models/status'), | ||
| Signature = require('../models/signature'), | ||
| getLogin = require('./get-user-login'), | ||
| rateLimit = require('./rate-limit.js'); | ||
| getLogin = require('./get-user-login'); | ||
|
|
||
| const github = new MyOctokit({ | ||
| auth: config.github.token, | ||
| throttle: { | ||
| onRateLimit: (retryAfter, options) => { | ||
| github.log.warn( | ||
| `Request quota exhausted for request ${options.method} ${options.url}` | ||
| ); | ||
|
|
||
| // Retry five times after hitting a rate limit error, then give up | ||
| if (options.request.retryCount <= 5) { | ||
| github.log.debug(`Retrying after ${retryAfter} seconds!`); | ||
| return true; | ||
| } | ||
| }, | ||
| onAbuseLimit: (retryAfter, options) => { | ||
| // does not retry, only logs a warning | ||
| github.log.warn( | ||
| `Abuse detected for request ${options.method} ${options.url}` | ||
| ); | ||
| }, | ||
| } | ||
| }); | ||
|
|
||
| const githubRest = github.rest; | ||
|
|
||
| github.authenticate({ | ||
| type: 'oauth', | ||
| token: config.github.token | ||
| }); | ||
|
|
||
| module.exports = { | ||
| github: github, | ||
| github: githubRest, | ||
|
|
||
| /** | ||
| * Returns a promise which resolves to a GitHub API response to | ||
| * a query for a particular Pull Request. | ||
| */ | ||
| getPull: function(repo, number) { | ||
| debug("Getting pull %s", number); | ||
| return rateLimit(github.pullRequests.get)(params({ number }, repo)) | ||
| .then(res => res.data); | ||
| return githubRest.pulls.get(params({ pull_number: number }, repo)) | ||
| .then(res => res.data); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -42,7 +61,7 @@ module.exports = { | |
| */ | ||
| getOpenPulls: function(repo) { | ||
| debug("Getting open pulls in repo %s", repo); | ||
| return rateLimit(github.pullRequests.getAll)(params({}, repo)).then(paginate); | ||
| return github.paginate(githubRest.pulls.list, params({state: 'open'}, repo)); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -52,8 +71,7 @@ module.exports = { | |
| */ | ||
| getAllPulls: function(repo) { | ||
| debug("Getting all pulls in repo %s", repo); | ||
| return rateLimit(github.pullRequests.getAll)(params({ state: 'all' }, repo)) | ||
| .then(paginate); | ||
| return github.paginate(githubRest.pulls.list, params({ state: 'all'}, repo)); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -62,11 +80,11 @@ module.exports = { | |
| * Returns a promise which resolves to a github issue | ||
| */ | ||
| getIssue: function(repo, number) { | ||
| const searchParams = params({ number }, repo); | ||
| const searchParams = params({ issue_number: number }, repo); | ||
| debug("Getting issue %s in repo %s", number, repo); | ||
| return rateLimit(github.issues.get)(searchParams) | ||
| .then(res => res.data) | ||
| .then(addRepo(searchParams)); | ||
| return githubRest.issues.get(searchParams) | ||
| .then(res => res.data) | ||
| .then(addRepo(searchParams)); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -75,12 +93,11 @@ module.exports = { | |
| * Returns a promise which resolves to an array of all open issues | ||
| */ | ||
| getOpenIssues: function(repo) { | ||
| const searchParams = params({}, repo); | ||
| debug("Getting open issues"); | ||
| return rateLimit(github.issues.getForRepo)(searchParams) | ||
| .then(paginate) | ||
| .then(filterOutPulls) | ||
| .then(addRepo(searchParams)); | ||
| const searchParams = params({state: 'open'}, repo); | ||
| debug("Getting open issues in repo %s", repo); | ||
| return github.paginate(githubRest.issues.listForRepo, searchParams) | ||
| .then(filterOutPulls) | ||
| .then(addRepo(searchParams)); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -91,10 +108,9 @@ module.exports = { | |
| getAllIssues: function(repo) { | ||
| const searchParams = params({state: 'all'}, repo); | ||
| debug("Getting all issues"); | ||
| return rateLimit(github.issues.getForRepo)(searchParams) | ||
| .then(paginate) | ||
| .then(filterOutPulls) | ||
| .then(addRepo(searchParams)); | ||
| return github.paginate(githubRest.issues.listForRepo, searchParams) | ||
| .then(filterOutPulls) | ||
| .then(addRepo(searchParams)); | ||
| }, | ||
|
|
||
| /** | ||
|
|
@@ -225,18 +241,6 @@ module.exports = { | |
| }, | ||
| }; | ||
|
|
||
| async function paginate(res) { | ||
| let response = res; | ||
| let all = res.data; | ||
|
|
||
| while (github.hasNextPage(response)) { | ||
| response = await rateLimit(github.getNextPage)(response); | ||
| all = all.concat(response.data); | ||
| } | ||
|
|
||
| return all; | ||
| } | ||
|
|
||
| /** | ||
| * Get array of Label objects from complete list of a Issue's events. | ||
| * | ||
|
|
@@ -322,7 +326,6 @@ function params(apiParams, fullRepoName) { | |
| return _.extend({ | ||
| owner, | ||
| repo, | ||
| per_page: 100 | ||
| }, apiParams); | ||
| } | ||
|
|
||
|
|
@@ -360,36 +363,31 @@ function parseRepo(repo) { | |
| */ | ||
| function getIssueEvents(repo, number) { | ||
| debug("Getting events for issue #%s", number); | ||
| return rateLimit(github.issues.getEvents)(params({ number }, repo)) | ||
| .then(paginate); | ||
| return github.paginate(githubRest.issues.listEvents, params({ issue_number: number }, repo)) | ||
| } | ||
|
|
||
| function getIssueComments(repo, number) { | ||
| debug("Getting comments for issue #%s", number); | ||
| return rateLimit(github.issues.getComments)(params({ number }, repo)) | ||
| .then(paginate); | ||
| return github.paginate(githubRest.issues.listComments, params({ issue_number: number }, repo)); | ||
| } | ||
|
|
||
| function getReviews(repo, number) { | ||
| debug("Getting reviews for pull #%s", number); | ||
| return rateLimit(github.pullRequests.listReviews)(params({ number }, repo)) | ||
| .then(paginate); | ||
| return github.paginate(githubRest.pulls.listReviews, params({ pull_number: number }, repo)); | ||
| } | ||
|
|
||
| function getPullReviewComments(repo, number) { | ||
| debug("Getting pull review comments for pull #%s", number); | ||
| return rateLimit(github.pullRequests.getComments)(params({ number }, repo)) | ||
|
addison-grant marked this conversation as resolved.
|
||
| .then(paginate); | ||
| return github.paginate(githubRest.pulls.listReviewComments, params({ pull_number: number }, repo)) | ||
| } | ||
|
|
||
| function getCommit(repo, sha) { | ||
| return rateLimit(github.repos.getCommit)(params({ sha }, repo)) | ||
| .then(res => res.data); | ||
| return githubRest.repos.getCommit(params({ ref: sha }, repo)).then(res => res.data); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure...I'll look into this.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is still needed because we need the data property off the response. Was there a particular reason you thought we don't need it? |
||
| } | ||
|
|
||
| function getCommitStatuses(repo, ref) { | ||
| debug("Getting commit status for %s", ref); | ||
| return rateLimit(github.repos.getCombinedStatusForRef)(params({ ref }, repo)) | ||
| return githubRest.repos.getCombinedStatusForRef(params({ ref }, repo)) | ||
| .then(res => res.data.statuses) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, will investigate
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is still needed because we need the particular sub-property off the response. Was there a particular reason you thought we don't need it? |
||
| .then(statuses => statuses || []) | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE reviews MODIFY body text |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test dev_block 👍
hello -Addison