@@ -3,12 +3,13 @@ import GitlabHelper from './gitlabHelper';
33import settings from '../settings' ;
44
55import { Octokit as GitHubApi } from '@octokit/rest' ;
6+ import { throttling } from '@octokit/plugin-throttling' ;
67import { Gitlab } from '@gitbeaker/node'
78
89import * as fs from 'fs' ;
910
1011import AWS from 'aws-sdk' ;
11-
12+ import { sleep } from './utils' ;
1213
1314const issueCounters = {
1415 nrOfPlaceholderIssues : 0 ,
@@ -51,8 +52,10 @@ const gitlabApi = new Gitlab({
5152 token : settings . gitlab . token ,
5253} ) ;
5354
55+ const MyOctokit = GitHubApi . plugin ( throttling ) ;
56+
5457// Create a GitHub API object
55- const githubApi = new GitHubApi ( {
58+ const githubApi = new MyOctokit ( {
5659 previews : settings . useIssueImportAPI ? [ "golden-comet" ] : [ ] ,
5760 debug : false ,
5861 baseUrl : settings . github . baseUrl
@@ -64,6 +67,22 @@ const githubApi = new GitHubApi({
6467 accept : 'application/vnd.github.v3+json' ,
6568 } ,
6669 auth : 'token ' + settings . github . token ,
70+ throttle : {
71+ onRateLimit : async ( retryAfter , options ) => {
72+ console . log (
73+ `Request quota exhausted for request ${ options . method } ${ options . url } `
74+ ) ;
75+ await sleep ( 60000 ) ;
76+ return true ;
77+ } ,
78+ onAbuseLimit : async ( retryAfter , options ) => {
79+ console . log (
80+ `Abuse detected for request ${ options . method } ${ options . url } `
81+ ) ;
82+ await sleep ( 60000 ) ;
83+ return true ;
84+ } ,
85+ } ,
6786} ) ;
6887
6988const gitlabHelper = new GitlabHelper ( gitlabApi , settings . gitlab ) ;
@@ -127,6 +146,7 @@ async function migrate() {
127146 try {
128147
129148 await githubHelper . registerRepoId ( ) ;
149+ await gitlabHelper . registerProjectPath ( settings . gitlab . projectId ) ;
130150
131151 // transfer GitLab milestones to GitHub
132152 if ( settings . transfer . milestones ) {
@@ -251,8 +271,6 @@ async function transferLabels(attachmentLabel = true, useLowerCase = true) {
251271async function transferIssues ( ) {
252272 inform ( 'Transferring Issues' ) ;
253273
254- await gitlabHelper . registerProjectPath ( settings . gitlab . projectId ) ;
255-
256274 // Because each
257275 let milestoneData = await githubHelper . getAllGithubMilestones ( ) ;
258276
0 commit comments