@@ -154,18 +154,20 @@ def init(self): # pragma: no cover
154
154
def _guess_repo_slug (self , repository , service ):
155
155
config = repository .config_reader ()
156
156
target = service .name
157
- for section_name in config .sections ():
158
- if 'remote' in section_name :
159
- section = dict (config .items (section_name ))
160
- if target in section ['url' ]:
161
- if section ['url' ].startswith ('https' ):
162
- * _ , user , name = section ['url' ].rstrip ('.git' ).split ('/' )
163
- self .set_repo_slug ('/' .join ([user , name ]))
164
- break
165
- elif section ['url' ].startswith ('git@' ):
166
- _ , repo_slug = section ['url' ].rstrip ('.git' ).split (':' )
167
- self .set_repo_slug (repo_slug )
168
- break
157
+ for remote in repository .remotes :
158
+ for url in remote .urls :
159
+ if url .startswith ('https' ):
160
+ if '.git' in url :
161
+ url = url [:- 4 ]
162
+ * _ , user , name = url .split ('/' )
163
+ self .set_repo_slug ('/' .join ([user , name ]))
164
+ break
165
+ elif url .startswith ('git@' ):
166
+ if '.git' in url :
167
+ url = url [:- 4 ]
168
+ _ , repo_slug = url .split (':' )
169
+ self .set_repo_slug (repo_slug )
170
+ break
169
171
170
172
def get_service (self , lookup_repository = True ):
171
173
if not lookup_repository :
@@ -181,7 +183,7 @@ def get_service(self, lookup_repository=True):
181
183
except InvalidGitRepositoryError :
182
184
raise FileNotFoundError ('Cannot find path to the repository.' )
183
185
service = RepositoryService .get_service (repository , self .target )
184
- if not self .repo_slug :
186
+ if not self .repo_name :
185
187
self ._guess_repo_slug (repository , service )
186
188
return service
187
189
0 commit comments