diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -150,8 +150,7 @@ class GitRepository(BaseRepository): bare=False): if create and os.path.exists(self.path): raise RepositoryError( - "Cannot create repository at %s, location already exist" - % self.path) + f"Cannot create repository at {self.path}, location already exist") if bare and do_workspace_checkout: raise RepositoryError("Cannot update a bare repository") @@ -162,8 +161,6 @@ class GitRepository(BaseRepository): GitRepository.check_url(src_url, self.config) if create: - os.makedirs(self.path, mode=0o755) - if bare: self._remote.init_bare() else: @@ -179,8 +176,7 @@ class GitRepository(BaseRepository): else: if not self._remote.assert_correct_path(): raise RepositoryError( - 'Path "%s" does not contain a Git repository' % - (self.path,)) + f'Path "{self.path}" does not contain a Git repository') # TODO: johbo: check if we have to translate the OSError here except OSError as err: diff --git a/rhodecode/lib/vcs/backends/svn/repository.py b/rhodecode/lib/vcs/backends/svn/repository.py --- a/rhodecode/lib/vcs/backends/svn/repository.py +++ b/rhodecode/lib/vcs/backends/svn/repository.py @@ -88,8 +88,7 @@ class SubversionRepository(base.BaseRepo def _init_repo(self, create, src_url): if create and os.path.exists(self.path): raise RepositoryError( - f"Cannot create repository at {self.path}, location already exist" - ) + f"Cannot create repository at {self.path}, location already exist") if create: self._remote.create_repository(settings.SVN_COMPATIBLE_VERSION) @@ -97,7 +96,9 @@ class SubversionRepository(base.BaseRepo src_url = _sanitize_url(src_url) self._remote.import_remote_repository(src_url) else: - self._check_path() + if not self._remote.is_path_valid_repository(self.path): + raise VCSError( + f'Path "{self.path}" does not contain a Subversion repository') @CachedProperty def commit_ids(self): @@ -243,13 +244,6 @@ class SubversionRepository(base.BaseRepo pass return False - def _check_path(self): - if not os.path.exists(self.path): - raise VCSError(f'Path "{self.path}" does not exist!') - if not self._remote.is_path_valid_repository(self.path): - raise VCSError( - 'Path "%s" does not contain a Subversion repository' % - (self.path, )) @LazyProperty def last_change(self):