repositories: use remote function to check if repo is empty

- changed 2 cases where we want to check for None instead of __bool__ of repo object
This commit is contained in:
Marcin Kuzminski 2019-06-05 13:30:26 +02:00
parent de07e75f22
commit 39e6f817c7
3 changed files with 6 additions and 3 deletions

View file

@ -244,7 +244,10 @@ class RepoAppView(BaseAppView):
c.repository_requirements_missing = {}
try:
self.rhodecode_vcs_repo = self.db_repo.scm_instance()
if self.rhodecode_vcs_repo:
# NOTE(marcink):
# comparison to None since if it's an object __bool__ is expensive to
# calculate
if self.rhodecode_vcs_repo is not None:
path_perms = self.rhodecode_vcs_repo.get_path_permissions(
c.auth_user.username)
self.path_filter = PathFilter(path_perms)

View file

@ -383,7 +383,7 @@ class BaseRepository(object):
return commit.size
def is_empty(self):
return not bool(self.commit_ids)
return self._remote.is_empty()
@staticmethod
def check_url(url, config):

View file

@ -2307,7 +2307,7 @@ class Repository(Base, BaseModel):
# use no-cache version here
scm_repo = self.scm_instance(cache=False, config=config)
empty = not scm_repo or scm_repo.is_empty()
empty = scm_repo is None or scm_repo.is_empty()
if not empty:
cs_cache = scm_repo.get_commit(
pre_load=["author", "date", "message", "parents"])