##// END OF EJS Templates
fixed issue with remote repos on git
marcink -
r2053:e121e10d beta
parent child Browse files
Show More
@@ -18,6 +18,7 b' fixes'
18 18 +++++
19 19
20 20 - fixed git protocol issues with repos-groups
21 - fixed git remote repos validator that prevented from cloning remote git repos
21 22
22 23 1.3.1 (**2012-02-27**)
23 24 ----------------------
@@ -345,32 +345,46 b' def SlugifyName():'
345 345
346 346
347 347 def ValidCloneUri():
348 from mercurial.httprepo import httprepository, httpsrepository
349 348 from rhodecode.lib.utils import make_ui
350 349
350 def url_handler(repo_type, url, proto, ui=None):
351 if repo_type == 'hg':
352 from mercurial.httprepo import httprepository, httpsrepository
353 if proto == 'https':
354 httpsrepository(make_ui('db'), url).capabilities
355 elif proto == 'http':
356 httprepository(make_ui('db'), url).capabilities
357 elif repo_type == 'git':
358 #TODO: write a git url validator
359 pass
360
351 361 class _ValidCloneUri(formencode.validators.FancyValidator):
352 362
353 363 def to_python(self, value, state):
354 if not value:
364
365 repo_type = value.get('repo_type')
366 url = value.get('clone_uri')
367 e_dict = {'clone_uri': _('invalid clone url')}
368
369 if not url:
355 370 pass
356 elif value.startswith('https'):
371 elif url.startswith('https'):
357 372 try:
358 httpsrepository(make_ui('db'), value).capabilities
373 url_handler(repo_type, url, 'https', make_ui('db'))
359 374 except Exception:
360 375 log.error(traceback.format_exc())
361 raise formencode.Invalid(_('invalid clone url'), value,
362 state)
363 elif value.startswith('http'):
376 raise formencode.Invalid('', value, state, error_dict=e_dict)
377 elif url.startswith('http'):
364 378 try:
365 httprepository(make_ui('db'), value).capabilities
379 url_handler(repo_type, url, 'http', make_ui('db'))
366 380 except Exception:
367 381 log.error(traceback.format_exc())
368 raise formencode.Invalid(_('invalid clone url'), value,
369 state)
382 raise formencode.Invalid('', value, state, error_dict=e_dict)
370 383 else:
371 raise formencode.Invalid(_('Invalid clone url, provide a '
372 'valid clone http\s url'), value,
373 state)
384 e_dict = {'clone_uri': _('Invalid clone url, provide a '
385 'valid clone http\s url')}
386 raise formencode.Invalid('', value, state, error_dict=e_dict)
387
374 388 return value
375 389
376 390 return _ValidCloneUri
@@ -645,8 +659,7 b' def RepoForm(edit=False, old_data={}, su'
645 659 filter_extra_fields = False
646 660 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
647 661 SlugifyName())
648 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False),
649 ValidCloneUri()())
662 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False))
650 663 repo_group = OneOf(repo_groups, hideList=True)
651 664 repo_type = OneOf(supported_backends)
652 665 description = UnicodeString(strip=True, min=1, not_empty=True)
@@ -658,7 +671,9 b' def RepoForm(edit=False, old_data={}, su'
658 671 #this is repo owner
659 672 user = All(UnicodeString(not_empty=True), ValidRepoUser)
660 673
661 chained_validators = [ValidRepoName(edit, old_data), ValidPerms()]
674 chained_validators = [ValidCloneUri()(),
675 ValidRepoName(edit, old_data),
676 ValidPerms()]
662 677 return _RepoForm
663 678
664 679
General Comments 0
You need to be logged in to leave comments. Login now