simplevcs: handle a case of damaged filesystem repo without 500 exception.

This commit is contained in:
Marcin Kuzminski 2017-11-16 16:31:18 +01:00
parent 4d9fa48377
commit a55c5ff1ea
3 changed files with 26 additions and 2 deletions

View file

@ -230,7 +230,8 @@ class SimpleVCS(object):
repo_name, db_repo.repo_type, scm_type)
return False
return is_valid_repo(repo_name, base_path, explicit_scm=scm_type)
return is_valid_repo(repo_name, base_path,
explicit_scm=scm_type, expect_scm=scm_type)
def valid_and_active_user(self, user):
"""

View file

@ -260,7 +260,7 @@ def is_valid_repo(repo_name, base_path, expect_scm=None, explicit_scm=None):
try:
if explicit_scm:
detected_scms = [get_scm_backend(explicit_scm)]
detected_scms = [get_scm_backend(explicit_scm)(full_path).alias]
else:
detected_scms = get_scm(full_path)

View file

@ -39,6 +39,7 @@ from rhodecode.lib.vcs.nodes import FileNode
from rhodecode.model.auth_token import AuthTokenModel
from rhodecode.model.db import Repository, UserIpMap, CacheKey
from rhodecode.model.meta import Session
from rhodecode.model.repo import RepoModel
from rhodecode.model.user import UserModel
from rhodecode.tests import (GIT_REPO, HG_REPO, TEST_USER_ADMIN_LOGIN)
@ -177,6 +178,28 @@ class TestVCSOperations(object):
'git clone', clone_url, tmpdir.strpath)
assert 'not found' in stderr
def test_clone_non_existing_store_path_hg(self, rc_web_server, tmpdir, user_util):
repo = user_util.create_repo()
clone_url = rc_web_server.repo_clone_url(repo.repo_name)
# Damage repo by removing it's folder
RepoModel()._delete_filesystem_repo(repo)
stdout, stderr = Command('/tmp').execute(
'hg clone', clone_url, tmpdir.strpath)
assert 'HTTP Error 404: Not Found' in stderr
def test_clone_non_existing_store_path_git(self, rc_web_server, tmpdir, user_util):
repo = user_util.create_repo(repo_type='git')
clone_url = rc_web_server.repo_clone_url(repo.repo_name)
# Damage repo by removing it's folder
RepoModel()._delete_filesystem_repo(repo)
stdout, stderr = Command('/tmp').execute(
'git clone', clone_url, tmpdir.strpath)
assert 'not found' in stderr
def test_push_new_file_hg(self, rc_web_server, tmpdir):
clone_url = rc_web_server.repo_clone_url(HG_REPO)
stdout, stderr = Command('/tmp').execute(