-
Notifications
You must be signed in to change notification settings - Fork 1k
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 poetry secondary source bug #4323
Merged
jurre
merged 8 commits into
dependabot:main
from
isobelhooper:fix-poetry-secondary-source-bug
Jan 7, 2022
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1c18f3e
Minor change: add pyproject.toml with private source to LatestVersion…
isobelhooper 4008ce3
Combine pyproject.toml and credential sources if they have the same a…
isobelhooper c62e44e
Add a test that PyprojectPreparer conserves tool.poetry.source names …
isobelhooper f565d15
Correctly merge pyproject_sources and variable sources with auth cred…
isobelhooper 9e2b4e3
Fix all problems flagged by rubocop in changed code
isobelhooper 166f513
Add test for PoetryFileUpdater with a python_index with auth details
isobelhooper f440e6d
For testing PoetryFileUpdater, use .prepared_pyproject
isobelhooper 0b2f93b
Merge branch 'main' into fix-poetry-secondary-source-bug
jurre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,8 +22,18 @@ def replace_sources(credentials) | |||||
pyproject_object = TomlRB.parse(pyproject_content) | ||||||
poetry_object = pyproject_object.fetch("tool").fetch("poetry") | ||||||
|
||||||
sources = pyproject_sources + config_variable_sources(credentials) | ||||||
poetry_object["source"] = sources if sources.any? | ||||||
sources_hash = pyproject_sources.map { |source| [source["url"], source] }.to_h | ||||||
|
||||||
for source in config_variable_sources(credentials) do | ||||||
if sources_hash.has_key?(source["original_url"]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will also fix this as part of the rubocop fixes. 👍 |
||||||
sources_hash[source["original_url"]]["url"] = source["url"] | ||||||
else | ||||||
source.delete("original_url") | ||||||
sources_hash[source["url"]] = source | ||||||
end | ||||||
end | ||||||
|
||||||
poetry_object["source"] = sources_hash.values if !sources_hash.empty? | ||||||
|
||||||
TomlRB.dump(pyproject_object) | ||||||
end | ||||||
|
@@ -105,6 +115,7 @@ def config_variable_sources(credentials) | |||||
select { |cred| cred["type"] == "python_index" }. | ||||||
map do |c| | ||||||
{ | ||||||
"original_url" => c["index-url"], | ||||||
"url" => AuthedUrlBuilder.authed_url(credential: c), | ||||||
"name" => SecureRandom.hex[0..3], | ||||||
"default" => c["replaces-base"] | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
python/spec/fixtures/pyproject_files/private_secondary_source.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[tool.poetry] | ||
name = "PythonProjects" | ||
version = "2.0.0" | ||
homepage = "https://github.com/roghu/py3_projects" | ||
license = "MIT" | ||
readme = "README.md" | ||
authors = ["Dependabot <support@dependabot.com>"] | ||
description = "Various small python projects." | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.7" | ||
requests = "2.18.0" | ||
internal = { version = "=1.2.3", source = "custom" } | ||
|
||
[[tool.poetry.source]] | ||
name = "custom" | ||
url = "https://some.internal.registry.com/pypi/" | ||
secondary = true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat nitty, but using
for
is discouraged in ruby,each
is faster and more idiomatic. Apologies for the nitpick 😬There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries! I'll change this as part of fixing what
rubocop
flags in the next commit.