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