Rename get_branch() to get_current_branch().

This commit is contained in:
Chris Jerdonek 2018-10-20 21:25:07 -07:00
parent 7696e7e530
commit cc9f03dea9
2 changed files with 6 additions and 6 deletions

View File

@ -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)

View File

@ -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):