File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -163,8 +163,11 @@ def sh(self, command):
163
163
return "" .join (lines )
164
164
165
165
def gitlab_create_remote (self , repo ):
166
+ # when using access token, gitlab doesn't care the username
167
+ url = self .gitlab ['git' ].replace (
168
+ 'https://' , 'https://user:{}@' .format (self .gitlab ['token' ]))
166
169
repo .create_remote ('gitlab' ,
167
- self . gitlab [ 'git' ] + "/" +
170
+ url + ( "/" if url . startswith ( 'http' ) else ':' ) +
168
171
self .gitlab ['namespace' ] + "/" +
169
172
self .gitlab ['name' ] + ".git" )
170
173
@@ -240,8 +243,12 @@ def git_mirror_optimize(self, repo):
240
243
241
244
def add_key (self ):
242
245
"Add ssh key to gitlab if necessary"
243
- with open (self .args .ssh_public_key ) as f :
244
- public_key = f .read ().strip ()
246
+ try :
247
+ with open (self .args .ssh_public_key ) as f :
248
+ public_key = f .read ().strip ()
249
+ except :
250
+ log .debug ("No key found in {}" .format (self .args .ssh_public_key ))
251
+ return None
245
252
g = self .gitlab
246
253
url = g ['url' ] + "/user/keys"
247
254
query = {'private_token' : g ['token' ]}
You can’t perform that action at this time.
0 commit comments