-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #5624: installing a Git ref for installs other than the first #5623
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix installing a Git ref for installs after the first. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,23 +180,52 @@ def test_git_with_tag_name_as_revision(script): | |
assert '0.1' in version.stdout | ||
|
||
|
||
@pytest.mark.network | ||
def test_git_with_ref_as_revision(script): | ||
def _add_ref(script, path, ref): | ||
""" | ||
Git backend should be able to install from a ref | ||
Add a new ref to a repository at the given path. | ||
""" | ||
version_pkg_path = _create_test_package(script) | ||
script.run( | ||
'git', 'update-ref', 'refs/foo/bar', 'HEAD', | ||
expect_stderr=True, | ||
cwd=version_pkg_path, | ||
) | ||
_change_test_package_version(script, version_pkg_path) | ||
script.pip( | ||
'install', '-e', '%s@refs/foo/bar#egg=version_pkg' % | ||
('git+file://' + version_pkg_path.abspath.replace('\\', '/')), | ||
expect_stderr=True | ||
) | ||
script.run('git', 'update-ref', ref, 'HEAD', expect_stderr=True, cwd=path) | ||
|
||
|
||
def make_version_pkg_url(path, revision=None): | ||
path = path.abspath.replace('\\', '/') | ||
url_rev = '' if revision is None else '@' + revision | ||
url = 'git+file://{}{}#egg=version_pkg'.format(path, url_rev) | ||
|
||
return url | ||
|
||
|
||
def test_git_install_ref(script): | ||
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. Seems like these tests lost the 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. The decorator is essentially for marking all tests that reach out to the network. 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. Yes, I removed it because I thought the Technically, I guess the Git docs do say that 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. The partitioning is so that you can run tests while not connected to the internet. If this test runs with no internet connectivity, then it doesn't need this decorator and vice versa. 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. Okay, I'll leave the decorator off then because as near as I can tell it doesn't require internet connectivity. |
||
""" | ||
The Git backend should be able to install a ref with the first install. | ||
""" | ||
package_path = _create_test_package(script) | ||
_add_ref(script, package_path, 'refs/foo/bar') | ||
_change_test_package_version(script, package_path) | ||
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. Is it necessary to run this here? 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. Yes, I think so because otherwise |
||
|
||
package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert '0.1' in version.stdout | ||
|
||
|
||
def test_git_install_then_install_ref(script): | ||
""" | ||
The Git backend should be able to install a ref after a package has | ||
already been installed. | ||
""" | ||
package_path = _create_test_package(script) | ||
_add_ref(script, package_path, 'refs/foo/bar') | ||
_change_test_package_version(script, package_path) | ||
|
||
package_url = make_version_pkg_url(package_path) | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert 'some different version' in version.stdout | ||
|
||
# Now install the ref. | ||
package_url = make_version_pkg_url(package_path, revision='refs/foo/bar') | ||
script.pip('install', '-e', package_url, expect_stderr=True) | ||
version = script.run('version_pkg') | ||
assert '0.1' in version.stdout | ||
|
||
|
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 think this could be more clear, it was not obvious to me what this change was about until I actually looked at the code. Perhaps "Allow a git ref to be installed over an existing non-ref install"
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.
Okay, I'll try rephrasing. The meaning was meant to be a bit more general actually -- allowing a Git ref to be installed over an existing install of any kind. Currently (without this PR), if it's the very first install (a "fresh" install), installing a Git ref works. But if it's the second or later install (i.e. an "update" to an install), then it doesn't work, no matter what the previous installs were. So the PR makes the latter case work, too.
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.
Right, so maybe "Allow a git ref to be installed over an existing installation" then?
That said I think most casual users are not going to understand this change regardless so perhaps it's fine as is. 🙂