Skip to content

Commit 1b4d4dc

Browse files
authored
Check API URL in GitLab private repo determination logic
1 parent 7ca8297 commit 1b4d4dc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

ymir/tools/privileged/gitlab.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040

4141

4242
_GITLAB_COMMIT_RE = re.compile(r"^/(.+?)/-/commit/([0-9a-f]+)\.(?:patch|diff)$", re.IGNORECASE)
43-
_REDHAT_PATH_PREFIX = "/redhat/"
43+
_REDHAT_WEB_PREFIX = "/redhat/"
44+
_REDHAT_API_PREFIX = "/api/v4/projects/redhat%2F"
4445

4546

4647
def _has_mock_url_rewrites() -> bool:
@@ -61,7 +62,9 @@ def _is_private_gitlab(url: str) -> bool:
6162
hostname = parsed.hostname or ""
6263
if hostname == "gitlab.cee.redhat.com":
6364
return True
64-
return hostname == "gitlab.com" and parsed.path.startswith(_REDHAT_PATH_PREFIX)
65+
if hostname != "gitlab.com":
66+
return False
67+
return parsed.path.startswith(_REDHAT_WEB_PREFIX) or parsed.path.startswith(_REDHAT_API_PREFIX)
6568

6669

6770
def _get_api_diff_url(url: str) -> str:

0 commit comments

Comments
 (0)