Skip to content

Commit 506f506

Browse files
committed
fix: #2
1 parent e58e111 commit 506f506

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ were never merged.
3838
--gitlab-url http://workbench.dachary.org \
3939
--gitlab-token sxQJ67SQKihMrGWVf \
4040
--gitlab-repo ceph/ceph-backports \
41-
--github-token 64933d355fda9844aadd4e224d \
41+
--github-auth githubusername:64933d355fda9844aadd4e224d \
4242
--github-repo ceph/ceph \
4343
--ignore-closed
4444
@@ -90,7 +90,7 @@ Hacking
9090
--gitlab-url http://workbench.dachary.org \
9191
--gitlab-token XXXXXXXXX \
9292
--gitlab-repo dachary/testrepo2 \
93-
--github-token XXXXXXXXX \
93+
--github-auth XXXXXXXXX \
9494
--github-repo dachary/testrepo \
9595
--ssh-public-key ~/.ssh/id_rsa.pub \
9696
--verbose

github2gitlab/main.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)