mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +01:00
Merge pull request #3086 from MartinFournier/fix/changelog-github-rate-limit
Slow down the fetch-changelog dev tool
This commit is contained in:
commit
5c45adb094
@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { Octokit } from "@octokit/rest";
|
||||
import commandLineArgs from "command-line-args";
|
||||
|
||||
@ -32,10 +33,10 @@ class MergeChangelog {
|
||||
sha: entry.sha,
|
||||
url: entry.html_url,
|
||||
user: {
|
||||
id: entry.author.id,
|
||||
login: entry.author.login,
|
||||
avatar: entry.author.avatar_url,
|
||||
url: entry.author.html_url,
|
||||
id: entry.author?.id,
|
||||
login: entry.author?.login,
|
||||
avatar: entry.author?.avatar_url,
|
||||
url: entry.author?.html_url,
|
||||
},
|
||||
commit_date: entry.commit.committer.date,
|
||||
message: entry.commit.message,
|
||||
@ -78,20 +79,19 @@ class MergeChangelog {
|
||||
searchResults.push(...entries);
|
||||
}
|
||||
|
||||
const pullRequestPromises = [];
|
||||
const pulls = [];
|
||||
for (const entry of searchResults) {
|
||||
pullRequestPromises.push(
|
||||
this.octokit.rest.pulls.get({
|
||||
owner, repo,
|
||||
pull_number: entry.number,
|
||||
}).then((response) => ({
|
||||
...entry,
|
||||
merge_commit_sha: response.data.merge_commit_sha,
|
||||
head_commit_sha: response.data.head.sha,
|
||||
const r = await (this.octokit.rest.pulls.get({
|
||||
owner, repo,
|
||||
pull_number: entry.number,
|
||||
}).then((response) => ({
|
||||
...entry,
|
||||
merge_commit_sha: response.data.merge_commit_sha,
|
||||
head_commit_sha: response.data.head.sha,
|
||||
})));
|
||||
pulls.push(r);
|
||||
await sleep(1000);
|
||||
}
|
||||
|
||||
const pulls = await Promise.all(pullRequestPromises);
|
||||
return pulls;
|
||||
}
|
||||
|
||||
@ -128,8 +128,9 @@ class MergeChangelog {
|
||||
const pullQuery = `user:${owner} repo:${repo} is:pr is:merged merged:"${from.date.toISOString()}..${to.date.toISOString()}"`;
|
||||
|
||||
const commits = await this.getCommitsSearchResults(commitQuery);
|
||||
await sleep(5000)
|
||||
const pulls = await this.getPullsSearchResults(pullQuery);
|
||||
|
||||
await sleep(5000)
|
||||
// We only have the merge commit sha & the HEAD sha in this data, but it can exclude some entries
|
||||
const pullsCommitSha = pulls.
|
||||
map((p) => [p.merge_commit_sha, p.head_commit_sha]).
|
||||
@ -234,6 +235,12 @@ ${commitLines.join('\n')}
|
||||
}
|
||||
}
|
||||
|
||||
const sleep = async (wait) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, wait)
|
||||
})
|
||||
}
|
||||
|
||||
const api = new MergeChangelog({ auth: process.env.GITHUB_API_TOKEN });
|
||||
api.getChangelog(cliArgs.from, cliArgs.to, cliArgs.detailed).then((data) => {
|
||||
console.log(data.log);
|
||||
|
Loading…
Reference in New Issue
Block a user