Skip to content
Snippets Groups Projects
Commit 288dc648 authored by Sushil Khanchi's avatar Sushil Khanchi :koala:
Browse files

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

parent 5f2066eb
No related branches found
No related tags found
1 merge request!64RepositoryService: implement CreateRepository
......@@ -82,19 +82,7 @@
# 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 @@
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment