-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Solving slashes or other less usual symbols in vcs refs were not being interpreted correctly. #5935
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9e5b0cd
Solving issue 5934 where slashes or other less usual symbols in vcs r…
matteius e107c3b
Do not modify lockfile format around subdirectories
matteius dff567d
add some new unit-style integrationt tests
matteius aa645fd
add news fragment.
matteius 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 hidden or 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 @@ | ||
Eveb better handling of vcs branch references that contain special characters. |
This file contains hidden or 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 hidden or 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 hidden or 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,63 @@ | ||
from collections import defaultdict | ||
import json | ||
import pytest | ||
|
||
from pipenv.project import Project | ||
from pipenv.utils import requirements | ||
|
||
|
||
@pytest.fixture | ||
def pypi_lockfile(): | ||
lockfile = defaultdict(dict) | ||
lockfile["_meta"] = { | ||
"sources": [ | ||
{ | ||
"name": "pypi", | ||
"url": "https://pypi.org/simple", | ||
"verify_ssl": True, | ||
} | ||
] | ||
} | ||
yield lockfile | ||
|
||
|
||
def test_git_branch_contains_slashes( | ||
pipenv_instance_pypi, pypi_lockfile | ||
): | ||
pypi_lockfile["default"]["google-api-python-client"] = { | ||
"git": "https://github.com/thehesiod/google-api-python-client.git@thehesiod/batch-retries2", | ||
"markers": "python_version >= '3.7'", | ||
"ref": "03803c21fc13a345e978f32775b2f2fa23c8e706" | ||
} | ||
|
||
with pipenv_instance_pypi() as p: | ||
with open(p.lockfile_path, "w") as f: | ||
json.dump(pypi_lockfile, f) | ||
|
||
project = Project() | ||
lockfile = project.load_lockfile(expand_env_vars=False) | ||
deps = lockfile["default"] | ||
pip_installable_lines = requirements.requirements_from_lockfile( | ||
deps, include_hashes=False, include_markers=True | ||
) | ||
assert pip_installable_lines == ["google-api-python-client@ git+https://github.com/thehesiod/google-api-python-client.git@03803c21fc13a345e978f32775b2f2fa23c8e706"] | ||
|
||
|
||
def test_git_branch_contains_subdirectory_fragment(pipenv_instance_pypi, pypi_lockfile): | ||
pypi_lockfile["default"]["pep508_package"] = { | ||
"git": "https://github.com/techalchemy/test-project.git@master", | ||
"subdirectory": "parent_folder/pep508-package", | ||
"ref": "03803c21fc13a345e978f32775b2f2fa23c8e706" | ||
} | ||
|
||
with pipenv_instance_pypi() as p: | ||
with open(p.lockfile_path, "w") as f: | ||
json.dump(pypi_lockfile, f) | ||
|
||
project = Project() | ||
lockfile = project.load_lockfile(expand_env_vars=False) | ||
deps = lockfile["default"] | ||
pip_installable_lines = requirements.requirements_from_lockfile( | ||
deps, include_hashes=False, include_markers=True | ||
) | ||
assert pip_installable_lines == ['pep508_package@ git+https://github.com/techalchemy/test-project.git@03803c21fc13a345e978f32775b2f2fa23c8e706#subdirectory=parent_folder/pep508-package'] |
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.
Will this test break if the branch is removed?
We should have an isolated test that does not depend on other people's repository.
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.
These are unit level tests but I had to do them as integration to leverage the pipfile/lockfile stuff we get from those fixtures, but I am starting to write tests that are more unit level in nature -- so we are really just testing the string conversions that happen through these constructs -- no actual lock resolution or installation happening in these tests. More like is it giving intelligible things to pip resolver or installer based on the inputs. For example, that commit hash was from a different test and not actually part of that repo.
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.
you can use your own repo with a fake branch too right?
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.
I don't care using mine, however I'm guessing you'll want to keep your own long term ;)
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.
You also submit a PR with the example files to plette repo. I started a collection of test cases there.