diff --git a/src/pip/_internal/vcs/git.py b/src/pip/_internal/vcs/git.py index 65722ceab..dc80a0532 100644 --- a/src/pip/_internal/vcs/git.py +++ b/src/pip/_internal/vcs/git.py @@ -79,7 +79,7 @@ class Git(VersionControl): version = '.'.join(version.split('.')[:3]) 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 (e.g. detached HEAD). @@ -210,7 +210,7 @@ class Git(VersionControl): if not self.is_commit_id_equal(dest, rev_options.rev): cmd_args = ['checkout', '-q'] + rev_options.to_args() 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 # is not yet checked out. track_branch = 'origin/{}'.format(branch_name) diff --git a/tests/functional/test_vcs_git.py b/tests/functional/test_vcs_git.py index be9020e21..9a51bf594 100644 --- a/tests/functional/test_vcs_git.py +++ b/tests/functional/test_vcs_git.py @@ -83,14 +83,14 @@ def test_get_remote_url(script, tmpdir): assert remote_url == source_url -def test_get_branch(script): +def test_get_current_branch(script): repo_dir = str(script.scratch_path) script.run('git', 'init', cwd=repo_dir) sha = do_commit(script, repo_dir) 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 # is alphabetically after. @@ -98,11 +98,11 @@ def test_get_branch(script): 'git', 'checkout', '-b', 'release', cwd=repo_dir, expect_stderr=True, ) - assert git.get_branch(repo_dir) == 'release' + assert git.get_current_branch(repo_dir) == 'release' # Also test the detached HEAD case. 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):