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) assert Git.get_current_branch(repo_dir) == 'master' # Switch to a branch with the same SHA as "master" but whose name # is alphabetically after. checkout_new_branch(script, repo_dir, 'release') assert Git.get_current_branch(repo_dir) == 'release' # Also test the detached HEAD case. checkout_ref(script, repo_dir, sha) assert Git.get_current_branch(repo_dir) is None
def test_get_current_branch__branch_and_tag_same_name(script, tmpdir): """ Check calling get_current_branch() from a branch or tag when the branch and tag have the same name. """ repo_dir = str(tmpdir) script.run('git', 'init', cwd=repo_dir) do_commit(script, repo_dir) checkout_new_branch(script, repo_dir, 'dev') # Create a tag with the same name as the branch. script.run('git', 'tag', 'dev', cwd=repo_dir) assert Git.get_current_branch(repo_dir) == 'dev' # Now try with the tag checked out. checkout_ref(script, repo_dir, 'refs/tags/dev') assert Git.get_current_branch(repo_dir) is None
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_current_branch(repo_dir) == 'master' # Switch to a branch with the same SHA as "master" but whose name # is alphabetically after. checkout_new_branch(script, repo_dir, 'release') assert git.get_current_branch(repo_dir) == 'release' # Also test the detached HEAD case. checkout_ref(script, repo_dir, sha) assert git.get_current_branch(repo_dir) is None
def test_get_current_branch__branch_and_tag_same_name(script, tmpdir): """ Check calling get_current_branch() from a branch or tag when the branch and tag have the same name. """ repo_dir = str(tmpdir) script.run('git', 'init', cwd=repo_dir) do_commit(script, repo_dir) checkout_new_branch(script, repo_dir, 'dev') # Create a tag with the same name as the branch. script.run('git', 'tag', 'dev', cwd=repo_dir) assert Git.get_current_branch(repo_dir) == 'dev' # Now try with the tag checked out. checkout_ref(script, repo_dir, 'refs/tags/dev') assert Git.get_current_branch(repo_dir) is None
def test_get_current_branch__branch_and_tag_same_name( script: PipTestEnvironment, tmpdir: pathlib.Path) -> None: """ Check calling get_current_branch() from a branch or tag when the branch and tag have the same name. """ repo_dir = str(tmpdir) script.run("git", "init", cwd=repo_dir) do_commit(script, repo_dir) checkout_new_branch(script, repo_dir, "dev") # Create a tag with the same name as the branch. script.run("git", "tag", "dev", cwd=repo_dir) assert Git.get_current_branch(repo_dir) == "dev" # Now try with the tag checked out. checkout_ref(script, repo_dir, "refs/tags/dev") assert Git.get_current_branch(repo_dir) is None