@@ -69,7 +69,7 @@ def __init__(self, args):
6969 'url' : "https://api.github.com" ,
7070 'git' : "https://github.com" ,
7171 'repo' : self .args .github_repo ,
72- 'token ' : self .args .github_token ,
72+ 'auth ' : self .args .github_auth or None
7373 }
7474 if self .args .branches :
7575 self .github ['branches' ] = self .args .branches .split (',' )
@@ -116,8 +116,8 @@ def get_parser():
116116 required = True )
117117 parser .add_argument ('--gitlab-repo' ,
118118 help = 'Gitlab repo (for instance ceph/ceph)' )
119- parser .add_argument ('--github-token ' ,
120- help = 'GitHub authentication token' )
119+ parser .add_argument ('--github-auth ' ,
120+ help = 'GitHub auth credentials, in the form username: token' )
121121 parser .add_argument ('--github-repo' ,
122122 help = 'GitHub repo (for instance ceph/ceph)' ,
123123 required = True )
@@ -197,9 +197,15 @@ def gitlab_create_remote(self, repo):
197197
198198 def git_mirror (self ):
199199 name = self .gitlab ['name' ]
200+ url = self .github ['git' ]
201+
202+ if (self .github ['auth' ]):
203+ url = self .github ['git' ].replace ('https://' , 'https://{}@' .format (self .github ['auth' ]))
204+
200205 if not os .path .exists (name ):
201- self .sh ("git clone --bare " + self . github [ 'git' ] +
206+ self .sh ("git clone --bare " + url +
202207 "/" + self .github ['repo' ] + " " + name )
208+
203209 repo = git .Repo (name )
204210 os .chdir (name )
205211 if not hasattr (repo .remotes , 'gitlab' ):
@@ -508,8 +514,8 @@ def get_pull_requests(self):
508514 "https://developer.github.com/v3/pulls/#list-pull-requests"
509515 g = self .github
510516 query = {'state' : 'all' }
511- if self . args . github_token :
512- query ['access_token' ] = g ['token' ]
517+ if g [ 'auth' ] :
518+ query ['access_token' ] = g ['auth' ]. split ( ':' )[ 1 ]
513519
514520 def f (pull ):
515521 if self .args .ignore_closed :
0 commit comments