Show More
@@ -654,7 +654,7 b' def get_host_info(request):' | |||||
654 | } |
|
654 | } | |
655 |
|
655 | |||
656 |
|
656 | |||
657 | def get_clone_url(request, uri_tmpl, repo_name, repo_id, **override): |
|
657 | def get_clone_url(request, uri_tmpl, repo_name, repo_id, repo_type, **override): | |
658 | qualified_home_url = request.route_url('home') |
|
658 | qualified_home_url = request.route_url('home') | |
659 | parsed_url = urlobject.URLObject(qualified_home_url) |
|
659 | parsed_url = urlobject.URLObject(qualified_home_url) | |
660 | decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/'))) |
|
660 | decoded_path = safe_unicode(urllib.unquote(parsed_url.path.rstrip('/'))) | |
@@ -668,7 +668,8 b' def get_clone_url(request, uri_tmpl, rep' | |||||
668 | 'hostname': parsed_url.hostname, |
|
668 | 'hostname': parsed_url.hostname, | |
669 | 'prefix': decoded_path, |
|
669 | 'prefix': decoded_path, | |
670 | 'repo': repo_name, |
|
670 | 'repo': repo_name, | |
671 | 'repoid': str(repo_id) |
|
671 | 'repoid': str(repo_id), | |
|
672 | 'repo_type': repo_type | |||
672 | } |
|
673 | } | |
673 | args.update(override) |
|
674 | args.update(override) | |
674 | args['user'] = urllib.quote(safe_str(args['user'])) |
|
675 | args['user'] = urllib.quote(safe_str(args['user'])) | |
@@ -676,6 +677,10 b' def get_clone_url(request, uri_tmpl, rep' | |||||
676 | for k, v in args.items(): |
|
677 | for k, v in args.items(): | |
677 | uri_tmpl = uri_tmpl.replace('{%s}' % k, v) |
|
678 | uri_tmpl = uri_tmpl.replace('{%s}' % k, v) | |
678 |
|
679 | |||
|
680 | # special case for SVN clone url | |||
|
681 | if repo_type == 'svn': | |||
|
682 | uri_tmpl = uri_tmpl.replace('ssh://', 'svn+ssh://') | |||
|
683 | ||||
679 | # remove leading @ sign if it's present. Case of empty user |
|
684 | # remove leading @ sign if it's present. Case of empty user | |
680 | url_obj = urlobject.URLObject(uri_tmpl) |
|
685 | url_obj = urlobject.URLObject(uri_tmpl) | |
681 | url = url_obj.with_netloc(url_obj.netloc.lstrip('@')) |
|
686 | url = url_obj.with_netloc(url_obj.netloc.lstrip('@')) |
@@ -2297,9 +2297,11 b' class Repository(Base, BaseModel):' | |||||
2297 | rc_config = request.call_context.rc_config |
|
2297 | rc_config = request.call_context.rc_config | |
2298 | else: |
|
2298 | else: | |
2299 | rc_config = SettingsModel().get_all_settings(cache=True) |
|
2299 | rc_config = SettingsModel().get_all_settings(cache=True) | |
|
2300 | ||||
2300 | if ssh: |
|
2301 | if ssh: | |
2301 | uri_tmpl = rc_config.get( |
|
2302 | uri_tmpl = rc_config.get( | |
2302 | 'rhodecode_clone_uri_ssh_tmpl') or self.DEFAULT_CLONE_URI_SSH |
|
2303 | 'rhodecode_clone_uri_ssh_tmpl') or self.DEFAULT_CLONE_URI_SSH | |
|
2304 | ||||
2303 | else: |
|
2305 | else: | |
2304 | uri_tmpl = rc_config.get( |
|
2306 | uri_tmpl = rc_config.get( | |
2305 | 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI |
|
2307 | 'rhodecode_clone_uri_tmpl') or self.DEFAULT_CLONE_URI | |
@@ -2307,7 +2309,9 b' class Repository(Base, BaseModel):' | |||||
2307 | return get_clone_url(request=request, |
|
2309 | return get_clone_url(request=request, | |
2308 | uri_tmpl=uri_tmpl, |
|
2310 | uri_tmpl=uri_tmpl, | |
2309 | repo_name=self.repo_name, |
|
2311 | repo_name=self.repo_name, | |
2310 |
repo_id=self.repo_id, |
|
2312 | repo_id=self.repo_id, | |
|
2313 | repo_type=self.repo_type, | |||
|
2314 | **override) | |||
2311 |
|
2315 | |||
2312 | def set_state(self, state): |
|
2316 | def set_state(self, state): | |
2313 | self.repo_state = state |
|
2317 | self.repo_state = state |
@@ -450,10 +450,27 b' def test_clone_url_generator(tmpl, repo_' | |||||
450 | clone_url = get_clone_url( |
|
450 | clone_url = get_clone_url( | |
451 | request=RequestStub(), |
|
451 | request=RequestStub(), | |
452 | uri_tmpl=tmpl, |
|
452 | uri_tmpl=tmpl, | |
453 | repo_name=repo_name, repo_id=23, **overrides) |
|
453 | repo_name=repo_name, repo_id=23, repo_type='hg', **overrides) | |
454 | assert clone_url == expected |
|
454 | assert clone_url == expected | |
455 |
|
455 | |||
456 |
|
456 | |||
|
457 | def test_clone_url_svn_ssh_generator(): | |||
|
458 | from rhodecode.lib.utils2 import get_clone_url | |||
|
459 | ||||
|
460 | class RequestStub(object): | |||
|
461 | def request_url(self, name): | |||
|
462 | return 'http://vps1:8000' | |||
|
463 | ||||
|
464 | def route_url(self, name): | |||
|
465 | return self.request_url(name) | |||
|
466 | ||||
|
467 | clone_url = get_clone_url( | |||
|
468 | request=RequestStub(), | |||
|
469 | uri_tmpl=Repository.DEFAULT_CLONE_URI_SSH, | |||
|
470 | repo_name='svn-test', repo_id=23, repo_type='svn', **{'sys_user': 'rcdev'}) | |||
|
471 | assert clone_url == 'svn+ssh://rcdev@vps1/svn-test' | |||
|
472 | ||||
|
473 | ||||
457 | idx = 0 |
|
474 | idx = 0 | |
458 |
|
475 | |||
459 |
|
476 |
General Comments 0
You need to be logged in to leave comments.
Login now