Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Project-URL metadata field to get a PyPI package's homepage URL #33089

Merged

Conversation

kemzeb
Copy link
Contributor

@kemzeb kemzeb commented Jan 3, 2025

Resolves #33085.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 3, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 3, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Jan 3, 2025
@kemzeb
Copy link
Contributor Author

kemzeb commented Jan 3, 2025

Still need to write some integration tests, but I tested this manually with a personal PyPI project that uses the Project-URL field to set the homepage. I uploaded it using the instructions from the Gitea docs and it uploaded just fine. I navigated to the package's homepage and can now see the project directory:

Before:
Screenshot 2025-01-02 at 5 49 10 PM

After:
Screenshot 2025-01-02 at 5 50 19 PM

Couple things:

  • I kept the Home-page metadata field around. Not sure if there are packages that use this field but just in case I kept it around. Let me know if we should just remove it
  • Since we have to loop over these URLs, should we set some arbitrary limit as to the number of URLs we should loop over?

Edit:

BTW, here are some references I used:

@kemzeb
Copy link
Contributor Author

kemzeb commented Jan 3, 2025

Going to open this. I did modify an integration test to test for project URL metadata but the existing tests are dependent on each other which makes it harder to add more. Let me know if I should do something about this

@kemzeb kemzeb marked this pull request as ready for review January 3, 2025 05:23
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 3, 2025
@kemzeb
Copy link
Contributor Author

kemzeb commented Jan 3, 2025

I understand the tests a tad more and was able to add the necessary coverage tests

// TODO: Home-page is a deprecated metadata field. Remove this form lookup once it's no longer apart of the spec.
homepageURL := ctx.Req.FormValue("home_page")
if len(homepageURL) == 0 {
projectURLs := ctx.Req.Form["project_urls"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

I think here it should use project_urls before home_page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 3, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 3, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 3, 2025
@lunny lunny enabled auto-merge (squash) January 3, 2025 20:44
@lunny lunny merged commit 188e0ee into go-gitea:main Jan 3, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.24.0 milestone Jan 3, 2025
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jan 3, 2025
@kemzeb kemzeb deleted the feat/api/use-project-url-to-get-homepage-url branch January 3, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files. topic/packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update PyPi package registry to use project.urls from pyproject.toml
4 participants