Skip to content

Commit

Permalink
fix(getfilecontributors): error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RobsonOlv committed Dec 22, 2023
1 parent 097b9fd commit dd2668a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/utils/getFileContributors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,27 @@ export default async function getFileContributors(
path: string
): Promise<unknown> {
const contributors: ContributorsType[] = []
const response = await octokit.rest.repos.listCommits({
owner,
repo,
sha: ref,
path,
})
try {
const response = await octokit.rest.repos.listCommits({
owner,
repo,
sha: ref,
path,
})

response.data.forEach((commitData: any) => {
if (!contributors.find((e) => e.login === commitData.author.login)) {
contributors.push({
name: commitData.commit.author.name,
login: commitData.author.login,
avatar: commitData.author.avatar_url,
userPage: commitData.author.html_url,
})
}
})
response.data.forEach((commitData: any) => {
if (!contributors.find((e) => e.login === commitData.author.login)) {
contributors.push({
name: commitData.commit.author.name,
login: commitData.author.login,
avatar: commitData.author.avatar_url,
userPage: commitData.author.html_url,
})
}
})
} catch (e: any) {
console.error(e.response.data.message)
}

return contributors
}
1 change: 1 addition & 0 deletions src/utils/octokitConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const octokitConfig = {
installationId: config.GITHUB_INSTALLATIONID,
},
throttle: {
enabled: false,
onRateLimit: (retryAfter: any, options: any, octokit: any) => {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
Expand Down

0 comments on commit dd2668a

Please sign in to comment.