Skip to content

Commit 625cb64

Browse files
committed
Merge branch requests/github/148 into devel
fixes #148
2 parents b14e648 + 0300d57 commit 625cb64

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

git_repo/repo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,15 @@ def _guess_repo_slug(self, repository, service, resolve_targets=None):
163163
for remote in repository.remotes:
164164
if remote.name in targets:
165165
for url in remote.urls:
166-
if url.startswith('https'):
167-
if url.endswith('.git'):
168-
url = url[:-4]
166+
if url.endswith('.git'):
167+
url = url[:-4]
168+
if url.find('://') > -1:
169+
# http://, https:// and ssh://
169170
*_, user, name = url.split('/')
170171
self.set_repo_slug('/'.join([user, name]))
171172
return
172-
elif url.startswith('git@'):
173-
if url.endswith('.git'):
174-
url = url[:-4]
173+
elif url.find('@') > -1 and url.find(':') > -1:
174+
# scp-style URL
175175
_, repo_slug = url.split(':')
176176
self.set_repo_slug(repo_slug)
177177
return

git_repo/services/service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ def format_path(self, repository, namespace=None, rw=False):
246246
if not rw and '/' in repo:
247247
return '{}/{}'.format(self.url_ro, repo)
248248
elif rw and '/' in repo:
249-
return '{}:{}'.format(self.url_rw, repo)
249+
if self.url_rw.startswith('ssh://'):
250+
return '{}/{}'.format(self.url_rw, repo)
251+
else:
252+
return '{}:{}'.format(self.url_rw, repo)
250253
else:
251254
raise ArgumentError("Cannot tell how to handle this url: `{}/{}`!".format(namespace, repo))
252255

0 commit comments

Comments
 (0)