Skip to content

Commit

Permalink
Initial implementation of GitLab statistics (#15931)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
nE0sIghT committed Sep 19, 2024
1 parent bdb71dc commit dccf3ee
Show file tree
Hide file tree
Showing 9 changed files with 338 additions and 73 deletions.
46 changes: 46 additions & 0 deletions tests/unit/packaging/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,52 @@ def test_verified_github_open_issueo_info_url_is_none_without_verified_url(
release = DBReleaseFactory.create()
assert release.verified_github_open_issue_info_url is None

@pytest.mark.parametrize(
("url", "expected"),
[
(
"https://gitlab.com/someuser/someproject",
"someuser/someproject",
),
(
"https://gitlab.com/someuser/someproject/",
"someuser/someproject",
),
(
"https://gitlab.com/someuser/someproject/-/tree/stable-9",
"someuser/someproject",
),
(
"https://www.gitlab.com/someuser/someproject",
"someuser/someproject",
),
("https://gitlab.com/someuser/", None),
("https://google.com/pypi/warehouse/tree/main", None),
("https://google.com", None),
("incorrect url", None),
(
"https://gitlab.com/someuser/someproject.git",
"someuser/someproject",
),
(
"https://www.gitlab.com/someuser/someproject.git/",
"someuser/someproject",
),
("[email protected]:definex/dsgnutils.git", None),
],
)
def test_verified_gitlab_repository(self, db_session, url, expected):
release = DBReleaseFactory.create()
release.project_urls["Homepage"] = {"url": url, "verified": True}
assert release.verified_gitlab_repository == expected

def test_verified_gitlab_repository_is_none_without_verified_url(
self,
db_session,
):
release = DBReleaseFactory.create()
assert release.verified_gitlab_repository is None

def test_trusted_published_none(self, db_session):
release = DBReleaseFactory.create()

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def test_includeme():
"'self'",
"https://api.github.com/repos/",
"https://api.github.com/search/issues",
"https://gitlab.com/api/",
"https://*.google-analytics.com",
"https://*.analytics.google.com",
"https://*.googletagmanager.com",
Expand Down
1 change: 1 addition & 0 deletions warehouse/csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _connect_src_settings(config) -> list:
SELF,
"https://api.github.com/repos/",
"https://api.github.com/search/issues",
"https://gitlab.com/api/",
"https://*.google-analytics.com",
"https://*.analytics.google.com",
"https://*.googletagmanager.com",
Expand Down
Loading

0 comments on commit dccf3ee

Please sign in to comment.