repo-creation: validate and forbid creating .git suffixed repository names.

- because of git-lfs support, and also becuase to support the clone of git bare repositories
we cannot allow creating such repositories.
This commit is contained in:
Marcin Kuzminski 2017-04-18 12:23:14 +02:00
parent 479c786358
commit b4b97b1b4e
4 changed files with 52 additions and 13 deletions

View file

@ -574,6 +574,26 @@ def SlugifyName():
return _validator
def CannotHaveGitSuffix():
class _validator(formencode.validators.FancyValidator):
messages = {
'has_git_suffix':
_(u'Repository name cannot end with .git'),
}
def _to_python(self, value, state):
return value
def validate_python(self, value, state):
if value and value.endswith('.git'):
msg = M(
self, 'has_git_suffix', state)
raise formencode.Invalid(
msg, value, state, error_dict={'repo_name': msg})
return _validator
def ValidCloneUri():
class InvalidCloneUrl(Exception):
allowed_prefixes = ()