Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/directory.py
Show All 35 Lines | def directory_browse(request, sha1_git, path=None): | ||||
""" | """ | ||||
root_sha1_git = sha1_git | root_sha1_git = sha1_git | ||||
try: | try: | ||||
if path: | if path: | ||||
dir_info = service.lookup_directory_with_path(sha1_git, path) | dir_info = service.lookup_directory_with_path(sha1_git, path) | ||||
sha1_git = dir_info['target'] | sha1_git = dir_info['target'] | ||||
dirs, files = get_directory_entries(sha1_git) | dirs, files = get_directory_entries(sha1_git) | ||||
origin_type = request.GET.get('origin_type', None) | |||||
origin_url = request.GET.get('origin_url', None) | origin_url = request.GET.get('origin_url', None) | ||||
if not origin_url: | if not origin_url: | ||||
origin_url = request.GET.get('origin', None) | origin_url = request.GET.get('origin', None) | ||||
snapshot_context = None | snapshot_context = None | ||||
if origin_url: | if origin_url: | ||||
try: | try: | ||||
snapshot_context = get_snapshot_context(None, origin_type, | snapshot_context = get_snapshot_context(origin_url=origin_url) | ||||
origin_url) | |||||
except Exception: | except Exception: | ||||
raw_dir_url = reverse('browse-directory', | raw_dir_url = reverse('browse-directory', | ||||
url_args={'sha1_git': sha1_git}) | url_args={'sha1_git': sha1_git}) | ||||
error_message = \ | error_message = \ | ||||
('The Software Heritage archive has a directory ' | ('The Software Heritage archive has a directory ' | ||||
'with the hash you provided but the origin ' | 'with the hash you provided but the origin ' | ||||
'mentioned in your request appears broken: %s. ' | 'mentioned in your request appears broken: %s. ' | ||||
'Please check the URL and try again.\n\n' | 'Please check the URL and try again.\n\n' | ||||
▲ Show 20 Lines • Show All 118 Lines • Show Last 20 Lines |