mirror of https://github.com/pypa/pip
use git fetch --tags
to fetch tags in addition to everything else that is normally fetched; this is necessary in case a git requirement url points to a tag or commit that is not on a branch
This commit is contained in:
parent
72a3d9cbfb
commit
4c4df9712a
|
@ -38,6 +38,10 @@
|
|||
|
||||
* Added pip completion support for fish shell.
|
||||
|
||||
* Use git fetch --tags to fetch tags in addition to everything else that
|
||||
is normally fetched; this is necessary in case a git requirement url
|
||||
points to a tag or commit that is not on a branch (:pull:`3791`)
|
||||
|
||||
|
||||
**8.1.2 (2016-05-10)**
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ from pip.compat import samefile
|
|||
from pip.exceptions import BadCommand
|
||||
from pip._vendor.six.moves.urllib import parse as urllib_parse
|
||||
from pip._vendor.six.moves.urllib import request as urllib_request
|
||||
from pip._vendor.packaging.version import parse as parse_version
|
||||
|
||||
from pip.utils import display_path, rmtree
|
||||
from pip.vcs import vcs, VersionControl
|
||||
|
@ -49,6 +50,19 @@ class Git(VersionControl):
|
|||
|
||||
super(Git, self).__init__(url, *args, **kwargs)
|
||||
|
||||
def get_git_version(self):
|
||||
VERSION_PFX = 'git version '
|
||||
version = self.run_command(['version'], show_stdout=False)
|
||||
if version.startswith(VERSION_PFX):
|
||||
version = version[len(VERSION_PFX):]
|
||||
else:
|
||||
version = ''
|
||||
# get first 3 positions of the git version becasue
|
||||
# on windows it is x.y.z.windows.t, and this parses as
|
||||
# LegacyVersion which always smaller than a Version.
|
||||
version = '.'.join(version.split('.')[:3])
|
||||
return parse_version(version)
|
||||
|
||||
def export(self, location):
|
||||
"""Export the Git repository at the url to the destination location"""
|
||||
temp_dir = tempfile.mkdtemp('-export', 'pip-')
|
||||
|
@ -99,7 +113,11 @@ class Git(VersionControl):
|
|||
|
||||
def update(self, dest, rev_options):
|
||||
# First fetch changes from the default remote
|
||||
self.run_command(['fetch', '-q'], cwd=dest)
|
||||
if self.get_git_version() >= parse_version('1.9.0'):
|
||||
# fetch tags in addition to everything else
|
||||
self.run_command(['fetch', '-q', '--tags'], cwd=dest)
|
||||
else:
|
||||
self.run_command(['fetch', '-q'], cwd=dest)
|
||||
# Then reset to wanted revision (maybe even origin/master)
|
||||
if rev_options:
|
||||
rev_options = self.check_rev_options(
|
||||
|
|
|
@ -5,6 +5,7 @@ from pip.vcs.bazaar import Bazaar
|
|||
from pip.vcs.git import Git
|
||||
from pip.vcs.subversion import Subversion
|
||||
from mock import Mock
|
||||
from pip._vendor.packaging.version import parse as parse_version
|
||||
|
||||
if pyversion >= '3':
|
||||
VERBOSE_FALSE = False
|
||||
|
@ -137,3 +138,8 @@ def test_subversion_remove_auth_from_url():
|
|||
expected_url = 'https://svnrepo.org/svn/project/trunk@8181'
|
||||
url = Subversion.remove_auth_from_url(svn_rev_url)
|
||||
assert url == expected_url
|
||||
|
||||
|
||||
def test_get_git_version():
|
||||
git_version = Git().get_git_version()
|
||||
assert git_version >= parse_version('1.0.0')
|
||||
|
|
Loading…
Reference in New Issue