Skip to content

Commit

Permalink
Don't assume master branch exists when reinstalling editable package …
Browse files Browse the repository at this point in the history
…from Git (#4450)

* Add failing test

* Don't assume master branch is default

* Don't expect output to stderr

* Use the 'short ref' instead of the 'full ref'
  • Loading branch information
di authored and xavfernandez committed Sep 29, 2017
1 parent e3288bb commit 8d96363
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions news/4448.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Reinstalling an editable package from Git no longer assumes that the ``master``
branch exists.
2 changes: 1 addition & 1 deletion src/pip/_internal/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def obtain(self, dest):
rev_options = [rev]
rev_display = ' (to %s)' % rev
else:
rev_options = ['origin/master']
rev_options = ['origin/HEAD']
rev_display = ''
if self.check_destination(dest, url, rev_options, rev_display):
logger.info(
Expand Down
29 changes: 29 additions & 0 deletions tests/functional/test_install_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,32 @@ def test_git_works_with_editable_non_origin_repo(script):
assert "Error when trying to get requirement" in result.stderr
assert "Could not determine repository location" in result.stdout
assert "version-pkg==0.1" in result.stdout


@pytest.mark.network
def test_reinstalling_works_with_editible_non_master_branch(script):
"""
Reinstalling an editable installation should not assume that the "master"
branch exists. See https://github.com/pypa/pip/issues/4448.
"""
version_pkg_path = _create_test_package(script)

# Switch the default branch to something other than 'master'
script.run('git', 'branch', '-m', 'foobar', cwd=version_pkg_path)

script.pip(
'install', '-e',
'%s#egg=version_pkg' %
('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
)
version = script.run('version_pkg')
assert '0.1' in version.stdout

_change_test_package_version(script, version_pkg_path)
script.pip(
'install', '-e',
'%s#egg=version_pkg' %
('git+file://' + version_pkg_path.abspath.replace('\\', '/')),
)
version = script.run('version_pkg')
assert 'some different version' in version.stdout

0 comments on commit 8d96363

Please sign in to comment.