mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Rename get_branch() to get_current_branch().
This commit is contained in:
parent
7696e7e530
commit
cc9f03dea9
|
@ -79,7 +79,7 @@ class Git(VersionControl):
|
||||||
version = '.'.join(version.split('.')[:3])
|
version = '.'.join(version.split('.')[:3])
|
||||||
return parse_version(version)
|
return parse_version(version)
|
||||||
|
|
||||||
def get_branch(self, location):
|
def get_current_branch(self, location):
|
||||||
"""
|
"""
|
||||||
Return the current branch, or None if HEAD isn't at a branch
|
Return the current branch, or None if HEAD isn't at a branch
|
||||||
(e.g. detached HEAD).
|
(e.g. detached HEAD).
|
||||||
|
@ -210,7 +210,7 @@ class Git(VersionControl):
|
||||||
if not self.is_commit_id_equal(dest, rev_options.rev):
|
if not self.is_commit_id_equal(dest, rev_options.rev):
|
||||||
cmd_args = ['checkout', '-q'] + rev_options.to_args()
|
cmd_args = ['checkout', '-q'] + rev_options.to_args()
|
||||||
self.run_command(cmd_args, cwd=dest)
|
self.run_command(cmd_args, cwd=dest)
|
||||||
elif self.get_branch(dest) != branch_name:
|
elif self.get_current_branch(dest) != branch_name:
|
||||||
# Then a specific branch was requested, and that branch
|
# Then a specific branch was requested, and that branch
|
||||||
# is not yet checked out.
|
# is not yet checked out.
|
||||||
track_branch = 'origin/{}'.format(branch_name)
|
track_branch = 'origin/{}'.format(branch_name)
|
||||||
|
|
|
@ -83,14 +83,14 @@ def test_get_remote_url(script, tmpdir):
|
||||||
assert remote_url == source_url
|
assert remote_url == source_url
|
||||||
|
|
||||||
|
|
||||||
def test_get_branch(script):
|
def test_get_current_branch(script):
|
||||||
repo_dir = str(script.scratch_path)
|
repo_dir = str(script.scratch_path)
|
||||||
|
|
||||||
script.run('git', 'init', cwd=repo_dir)
|
script.run('git', 'init', cwd=repo_dir)
|
||||||
sha = do_commit(script, repo_dir)
|
sha = do_commit(script, repo_dir)
|
||||||
|
|
||||||
git = Git()
|
git = Git()
|
||||||
assert git.get_branch(repo_dir) == 'master'
|
assert git.get_current_branch(repo_dir) == 'master'
|
||||||
|
|
||||||
# Switch to a branch with the same SHA as "master" but whose name
|
# Switch to a branch with the same SHA as "master" but whose name
|
||||||
# is alphabetically after.
|
# is alphabetically after.
|
||||||
|
@ -98,11 +98,11 @@ def test_get_branch(script):
|
||||||
'git', 'checkout', '-b', 'release', cwd=repo_dir,
|
'git', 'checkout', '-b', 'release', cwd=repo_dir,
|
||||||
expect_stderr=True,
|
expect_stderr=True,
|
||||||
)
|
)
|
||||||
assert git.get_branch(repo_dir) == 'release'
|
assert git.get_current_branch(repo_dir) == 'release'
|
||||||
|
|
||||||
# Also test the detached HEAD case.
|
# Also test the detached HEAD case.
|
||||||
script.run('git', 'checkout', sha, cwd=repo_dir, expect_stderr=True)
|
script.run('git', 'checkout', sha, cwd=repo_dir, expect_stderr=True)
|
||||||
assert git.get_branch(repo_dir) is None
|
assert git.get_current_branch(repo_dir) is None
|
||||||
|
|
||||||
|
|
||||||
def test_get_revision_sha(script):
|
def test_get_revision_sha(script):
|
||||||
|
|
Loading…
Reference in a new issue