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

Fix git detection #811

Merged
merged 3 commits into from
Aug 25, 2023
Merged

Fix git detection #811

merged 3 commits into from
Aug 25, 2023

Conversation

nmburgan
Copy link
Contributor

@nmburgan nmburgan commented Aug 24, 2023

(maint) Fix git remote detection

Previously, this was attempting to determine if a github.com URL was a remote or a media type by inspecting part of the path. However, this was missing paths with 'release' in them. Also, we were never actually using any other return type but :github_remote. This changes the logic to return :github_media if the path contains known media tokens, or if the suffix ends with .tar.gz or .zip. Otherwise, we assume it's a remote.

Ideally, we'd reach out to GitHub to determine if it's a repo, but we're doing this to avoid rate limiting.

(maint) Fix valid_url? check

Because the 'request' function does NOT return the value the block you pass it returns, this function was always returning a Net::HTTP object. With how this function was being used, it would result in valid_url? always being truthy. Net::HTTP.start DOES return the value that the block you pass it returns, though, so this simply un-blockifies the processing of the request response.

@nmburgan nmburgan requested a review from a team as a code owner August 24, 2023 23:21
@nmburgan
Copy link
Contributor Author

Apparently, /tarball/ and /zipball/ are still valid paths that result in a tarball and zipball, at least on some repos. Putting some of that back in.

@nmburgan nmburgan force-pushed the fix_git_detection branch 2 times, most recently from 87de447 to 8d5cc96 Compare August 25, 2023 00:18
Nick Burgan-Illig added 3 commits August 25, 2023 00:25
Previously, this was attempting to determine if a github.com URL was a remote or a media type by inspecting part of the path. However, this was missing paths with 'release' in them. Also, we were never actually using any other return type but :github_remote. This changes the logic to return :github_media if the path contains known media tokens, or if the suffix ends with .tar.gz or .zip. Otherwise, we assume it's a remote.

Ideally, we'd reach out to GitHub to determine if it's a repo, but we're doing this to avoid rate limiting.
Because the 'request' function does NOT return the value the block you pass it returns, this function was always returning a Net::HTTP object. With how this function was being used, it would result in valid_url? always being truthy.  Net::HTTP.start DOES return the value that the block you pass it returns, though, so this simply un-blockifies the processing of the request response.
@nmburgan
Copy link
Contributor Author

Alright, I think it's good now.

@e-gris e-gris merged commit 78dbe9c into puppetlabs:main Aug 25, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants