Skip to content

Commit dccf3ee

Browse files
authored
Initial implementation of GitLab statistics (#15931)
* Initial implementation of GitLab statistics Issue: #12789 Signed-off-by: Yuri Konotopov <[email protected]> * project-data: fixed Gitlab's repository icon * csp: limit Gitlab urls to /api/ * gitlab: use "starrers" term instead of "stargazers" and "followers" * gitlab: `MR` abbreviation revealed * gitlab: log errors to console instead of hiding them completely --------- Signed-off-by: Yuri Konotopov <[email protected]>
1 parent bdb71dc commit dccf3ee

File tree

9 files changed

+338
-73
lines changed

9 files changed

+338
-73
lines changed

tests/unit/packaging/test_models.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,52 @@ def test_verified_github_open_issueo_info_url_is_none_without_verified_url(
977977
release = DBReleaseFactory.create()
978978
assert release.verified_github_open_issue_info_url is None
979979

980+
@pytest.mark.parametrize(
981+
("url", "expected"),
982+
[
983+
(
984+
"https://gitlab.com/someuser/someproject",
985+
"someuser/someproject",
986+
),
987+
(
988+
"https://gitlab.com/someuser/someproject/",
989+
"someuser/someproject",
990+
),
991+
(
992+
"https://gitlab.com/someuser/someproject/-/tree/stable-9",
993+
"someuser/someproject",
994+
),
995+
(
996+
"https://www.gitlab.com/someuser/someproject",
997+
"someuser/someproject",
998+
),
999+
("https://gitlab.com/someuser/", None),
1000+
("https://google.com/pypi/warehouse/tree/main", None),
1001+
("https://google.com", None),
1002+
("incorrect url", None),
1003+
(
1004+
"https://gitlab.com/someuser/someproject.git",
1005+
"someuser/someproject",
1006+
),
1007+
(
1008+
"https://www.gitlab.com/someuser/someproject.git/",
1009+
"someuser/someproject",
1010+
),
1011+
("[email protected]:definex/dsgnutils.git", None),
1012+
],
1013+
)
1014+
def test_verified_gitlab_repository(self, db_session, url, expected):
1015+
release = DBReleaseFactory.create()
1016+
release.project_urls["Homepage"] = {"url": url, "verified": True}
1017+
assert release.verified_gitlab_repository == expected
1018+
1019+
def test_verified_gitlab_repository_is_none_without_verified_url(
1020+
self,
1021+
db_session,
1022+
):
1023+
release = DBReleaseFactory.create()
1024+
assert release.verified_gitlab_repository is None
1025+
9801026
def test_trusted_published_none(self, db_session):
9811027
release = DBReleaseFactory.create()
9821028

tests/unit/test_csp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ def test_includeme():
249249
"'self'",
250250
"https://api.github.com/repos/",
251251
"https://api.github.com/search/issues",
252+
"https://gitlab.com/api/",
252253
"https://*.google-analytics.com",
253254
"https://*.analytics.google.com",
254255
"https://*.googletagmanager.com",

warehouse/csp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def _connect_src_settings(config) -> list:
9797
SELF,
9898
"https://api.github.com/repos/",
9999
"https://api.github.com/search/issues",
100+
"https://gitlab.com/api/",
100101
"https://*.google-analytics.com",
101102
"https://*.analytics.google.com",
102103
"https://*.googletagmanager.com",

0 commit comments

Comments
 (0)