Skip to content

Commit f6e049a

Browse files
committed
Merge branch 'feature/gl-support-empty-repos' into develop
[OSF-8169]
2 parents 966fbd9 + 1acb483 commit f6e049a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

waterbutler/providers/gitlab/provider.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ async def _metadata_file(self, path: GitLabPath) -> GitLabFileMetadata:
368368

369369
# GitLab currently returns 200 OK for nonexistent directories
370370
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/34016
371-
# Fallback: empty directories shouldn't exist in git,
372-
if page_nbr == 1 and len(data_page) == 0:
371+
# Fallback: empty directories shouldn't exist in git, unless it's the root
372+
if page_nbr == 1 and len(data_page) == 0 and not path.is_root:
373373
raise exceptions.NotFoundError(path.full_path)
374374

375375
if page_nbr == 1:
@@ -451,14 +451,15 @@ async def _fetch_tree_contents(self, path: GitLabPath) -> list:
451451
throws=exceptions.NotFoundError,
452452
)
453453
if resp.status == 404:
454+
await resp.release()
454455
raise exceptions.NotFoundError(path.full_path)
455456

456457
data_page = await resp.json()
457458

458459
# GitLab currently returns 200 OK for nonexistent directories
459460
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/34016
460-
# Fallback: empty directories shouldn't exist in git,
461-
if page_nbr == 1 and len(data_page) == 0:
461+
# Fallback: empty directories shouldn't exist in git, unless it's the root
462+
if page_nbr == 1 and len(data_page) == 0 and not path.is_root:
462463
raise exceptions.NotFoundError(path.full_path)
463464

464465
data.extend(data_page)
@@ -511,7 +512,7 @@ async def _get_commit_sha_for_branch(self, branch_name: str) -> str:
511512

512513
def _convert_ruby_hash_to_dict(self, ruby_hash: str) -> dict:
513514
"""Adopted from https://stackoverflow.com/a/19322785 as a workaround for
514-
https://gitlab.com/gitlab-org/gitlab-ce/issues/34016. Fixed in GL v9.5
515+
https://gitlab.com/gitlab-org/gitlab-ce/issues/31790. Fixed in GL v9.5
515516
516517
:param str ruby_hash: serialized Ruby hash
517518
:rtype: `dict`

0 commit comments

Comments
 (0)