提交 d1b94415 编写于 作者: C Chris Jerdonek

Change check_version() to accept a commit hash / id.

上级 3e4f8089
......@@ -279,7 +279,7 @@ class VersionControl(object):
"""
raise NotImplementedError
def check_version(self, dest, rev_options):
def check_version(self, dest, commit_id):
"""
Return True if the version is identical to what exists and
doesn't need to be updated.
......@@ -313,7 +313,8 @@ class VersionControl(object):
display_path(dest),
url,
)
if not self.check_version(dest, rev_options):
commit_id = rev_options[0]
if not self.check_version(dest, commit_id):
logger.info(
'Updating %s %s%s',
display_path(dest),
......
......@@ -104,7 +104,7 @@ class Bazaar(VersionControl):
current_rev = self.get_revision(location)
return '%s@%s#egg=%s' % (repo, current_rev, egg_project_name)
def check_version(self, dest, rev_options):
def check_version(self, dest, commit_id):
"""Always assume the versions don't match"""
return False
......
......@@ -119,7 +119,7 @@ class Git(VersionControl):
return rev_options
def check_version(self, dest, rev_options):
def check_version(self, dest, commit_id):
"""
Compare the current sha to the ref. ref may be a branch or tag name,
but current rev will always point to a sha. This means that a branch
......@@ -129,7 +129,7 @@ class Git(VersionControl):
Args:
rev_options: a RevOptions object.
"""
return self.get_revision(dest) == rev_options.arg_rev
return self.get_revision(dest) == commit_id
def switch(self, dest, url, rev_options):
self.run_command(['config', 'remote.origin.url', url], cwd=dest)
......@@ -164,10 +164,11 @@ class Git(VersionControl):
if rev:
rev_options = self.check_rev_options(dest, rev_options)
# Only do a checkout if rev_options differs from HEAD
if not self.check_version(dest, rev_options):
commit_hash = rev_options.rev
# Only do a checkout if HEAD differs from commit_hash.
if not self.check_version(dest, commit_hash):
cmd_args = ['fetch', '-q', url] + rev_options.to_args()
self.run_command(cmd_args, cwd=dest,)
self.run_command(cmd_args, cwd=dest)
self.run_command(
['checkout', '-q', 'FETCH_HEAD'],
cwd=dest,
......
......@@ -97,7 +97,7 @@ class Mercurial(VersionControl):
current_rev_hash = self.get_revision_hash(location)
return '%s@%s#egg=%s' % (repo, current_rev_hash, egg_project_name)
def check_version(self, dest, rev_options):
def check_version(self, dest, commit_id):
"""Always assume the versions don't match"""
return False
......
......@@ -217,7 +217,7 @@ class Subversion(VersionControl):
rev = self.get_revision(location)
return 'svn+%s@%s#egg=%s' % (repo, rev, egg_project_name)
def check_version(self, dest, rev_options):
def check_version(self, dest, commit_id):
"""Always assume the versions don't match"""
return False
......
......@@ -118,16 +118,15 @@ def test_git_get_src_requirements(git, dist):
])
@pytest.mark.parametrize('ref,result', (
@pytest.mark.parametrize('commit,result', (
('5547fa909e83df8bd743d3978d6667497983a4b7', True),
('5547fa909', False),
('5678', False),
('abc123', False),
('foo', False),
))
def test_git_check_version(git, ref, result):
rev_options = git.make_rev_options(ref)
assert git.check_version('foo', rev_options) is result
def test_git_check_version(git, commit, result):
assert git.check_version('/path', commit) is result
def test_translate_egg_surname():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册