Commit d1293d2a authored by Sushil Khanchi's avatar Sushil Khanchi 🐨
Browse files

servicer: extract logic to find repo disk path in a method

parent 5f2066eb55f6
......@@ -82,19 +82,7 @@ class HGitalyServicer:
# shamelessly taken from heptapod.wsgi for the Hgitaly bootstrap
# note that Gitaly Repository has more than just a relative path,
# we'll have to decide what we make of the extra information
rpath = repository.relative_path
if rpath.endswith('.git'):
rpath = rpath[:-4] + '.hg'
root_dir = self.storages.get(repository.storage_name)
if root_dir is None:
context.set_code(StatusCode.NOT_FOUND)
context.set_details(
"No storage named %r" % repository.storage_name)
raise KeyError('storage', repository.storage_name)
# GitLab filesystem paths are always ASCII
repo_path = os.path.join(root_dir, rpath.encode('ascii'))
repo_path = self.repo_disk_path(repository, context)
logger.info("loading repo at %r", repo_path)
try:
......@@ -110,3 +98,19 @@ class HGitalyServicer:
srcrepo.unfiltered().__class__)
return repo
def repo_disk_path(self, repository: Repository, context):
rpath = repository.relative_path
if rpath.endswith('.git'):
rpath = rpath[:-4] + '.hg'
root_dir = self.storages.get(repository.storage_name)
if root_dir is None:
context.set_code(StatusCode.NOT_FOUND)
context.set_details(
"No storage named %r" % repository.storage_name)
raise KeyError('storage', repository.storage_name)
# GitLab filesystem paths are always ASCII
repo_path = os.path.join(root_dir, rpath.encode('ascii'))
return repo_path
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment